2016-10-17 28 views
0

私は相対レイアウトで2つのテキストビューを持っています。最初のtextviewのサイズは固定で、2番目のtextviewのサイズは動的です。私はすべての利用可能な幅want output like thisを埋めるために私の2番目のテキストビューが欲しいが、私はこれを行うことができません。出来ますか? 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

2つの別々のTextViewで構築することはできません。たとえば、SpannableStringを試してください。下記のpawegioのようなもの。 – Mike

答えて

2

あなたがテキストとしてSpannableStringとコンテンツの両方のセクションのための単一のTextViewを使用することができます。 exampleを参照してください。

+0

ありがとう。私はあなたの方法に従って、私は希望の出力を達成することができますが、背景色のスパンにパディングを設定する方法。 –

+0

私のコード:String resposne = "Flaticon Basic License。 著者に必要です。アイコンの作者にどのようにクレジットを与えるのですか? SpannableString styledString =新しいSpannableString( "管理のマッサージ - " + resposne);styledString.setSpan(new 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

'draw()'メソッドにアクセスするためにカスタムの 'ReplacementSpan'が必要です。 [this](http://stackoverflow.com/a/29023947/1432752)を参照してください。 – pawegio

関連する問題