2016-08-11 13 views
0

テキストの左側に縦線を追加するにはどうすればよいですか?
私はTextViewにブロッククォートhtmlを動的に表示しています。テキストの左側に縦線を追加するにはどうすればいいですか?

refer image

+0

**複合複写可能**(この場合は 'drawableLeft')を使用して、追加の表示に保存することもできます。 –

+0

あなたはもっと説明できますか? –

+0

「android textview compound drawable」のgoogleをお願いします –

答えて

1

textViewの左側に置き、希望する寸法と色を使用してください。 HTMLテキストここ

WebView webview = (WebView)this.findViewById(R.id.webview); 
    webview.getSettings().setJavaScriptEnabled(true); 
    webview.loadDataWithBaseURL("", data, "text/html", "UTF-8", ""); 

ため

 <View 
     android:layout_width="2dp" 
     android:layout_height="100dp" 
     android:background="@color/colorPrimaryDark"></View> 
+0

textviewを動的に作成したい、HTMLからテキストを設定したいです。 –

1

使用

<View android:id="@+id/view" 
      android:layout_height="match_parent" 
      android:layout_width="1dp" 
      android:background="#000000" /> 

使用WebViewのは、あなたが

 String a = "You can "; 
     String b = "change" ; 
     String c = "like this" ; 
     String d = "if want to make it bold"; 
     String sourceString = a + " " + "<b>" + b + "</b>" + " " + c + " " + "<b>" + d + "</b>"; 
     textView.setText(Html.fromHtml(sourceString)); 

はそれが

のようになりますしたいコードです

ことはでき変更このようそれは大胆

+0

テキストビューを動的に作成し、テキストをhtmlから設定したい。 –

+0

check編集済み返信@BincyBaby –

+0

webviewを使わずに –

1

あなたがView使用できるようにしたい場合:Htmlを示すために

enter image description here

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:padding="10dp" 
    android:orientation="horizontal"> 

    <View 
    android:layout_gravity="right" 
    android:background="#000000" 
    android:layout_width="2dp" 
    android:layout_marginLeft="20dp" 
    android:layout_marginRight="20dp" 
    android:layout_height="match_parent" /> 

    <TextView 
    android:text="balblalblablalblablalblalb" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" /> 

</LinearLayout> 

は、それは次のようになりますあなたは次のようにすることができます:

yourTextView.setText(Html.fromHtml("your html string")); 
+0

を説明してください。textviewを動的に作成し、テキストをhtmlから設定してください。 –

+0

'TextView'を動的に作成することができます:' TextView t =新しいTextView(コンテキスト); 'あなたのニーズに基づいて' LayoutParams'を設定するより – hrskrs

0
Step 1: Add a Linear layout in a layout. 
<LinearLayout 
    android:id="@+id/linear_layout" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="horizontal" 
    android:layout_margin="10dp"> 

</LinearLayout> 
step2:In Activity , create TextView and a View dynamically add to linear layout 
LinearLayout mylayout = (LinearLayout) findViewById(R.id.linear_layout); 

    TextView text = new TextView(this); 
    text.setText("Testing"); 

    View view = new View(this); 
    view.setBackgroundColor(getResources().getColor(R.color.black)); 
    view.setLayoutParams(new LinearLayout.LayoutParams(5, LinearLayout.LayoutParams.MATCH_PARENT)); 

    mylayout.addView(view,0); 
    mylayout.addView(text,1); 

希望します。

関連する問題