2016-10-17 7 views
0

У меня есть два текстовых изображения в относительной компоновке. первый размер текстового вида фиксирован, а второй размер текстового вида - динамический. Я хочу, чтобы мое второе текстовое изображение заполнило всю доступную ширину want output like this, но я не могу этого сделать. Является ли это возможным? this is what i am getting right nowТекстовая заливка доступной ширины

Мой XML:

<RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginTop="@dimen/ten_dp"> 

     <com.staff_have_says.utitlies.MyTextViewBold 
      android:id="@+id/banner" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="Massage To Management" 
      android:background="@android:color/holo_green_dark" 
      android:padding="@dimen/ten_dp" 
      android:textColor="@color/white" 
     /> 

     <TextView 

      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_toEndOf="@id/banner" 
      android:text="Flaticon Basic License. It's necessary to credit the author. How to credit the authorship of the icons?Flaticon Basic License. It's necessary to credit the author. How to credit the authorship of the icons?" 

      /> 
    </RelativeLayout> 
+0

Показать код 'xml'. –

+0

@jaydroider Я опубликовал that.check отредактировал. –

+0

Вы не можете создать это с помощью двух отдельных текстовых элементов. Например, попробуйте SpannableString. Что-то вроде pawegio, упомянутое ниже. – Mike

ответ

2

Вы можете использовать один TextView для обоих разделов вашего контента с SpannableString как текст. См. example.

+0

спасибо. Я следил за вашим методом, и я могу достичь желаемого вывода, но как установить дополнение к цвету фона. –

+0

мой код: String resposne = "Flaticon Basic License. Необходимо, чтобы автор. Как заручиться авторством значков?"; SpannableString styledString = новый SpannableString («Массаж для управления -» + resposne); styledString.setSpan (новый BackgroundColorSpan (Color.GREEN), 0, 21, 0); styledString.setSpan (новый RelativeSizeSpan (1.5f), 0, 21, 0); TextView textView = (TextView) rootview.findViewById (R.id.banner); textView.setText (styledString); –

+0

Он требует специального 'ReplacementSpan' с доступом к методу' draw() '. См. [This] (http://stackoverflow.com/a/29023947/1432752). – pawegio

Смежные вопросы