2

私はTextViewJavaコーディングを介して作成しましたが、コーディングを介して境界線を描画する必要があります。以下の私のコードを参照してください、

TextView txt = new TextView(this);
txt.setText("SEARCH TABLE");
txt.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
txt.setFadingEdgeLength(10);
txt.setTextColor(Color.WHITE);
txt.setBackgroundColor(Color.rgb(83,82,82));
txt.setPadding(10, 5, 10, 0);
txt.setGravity(Gravity.CENTER);
txt.setTypeface(Typeface.SERIF,Typeface.BOLD);

どうやってするの ?

4

1 に答える 1

5

ビューの背景として図形描画可能(長方形)を設定できます。

txt.setBackgroundDrawable(getResources().getDrawable(R.drawable.black));

そして長方形のdrawableback.xml(res / drawableフォルダーに入れられます):

<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >    
<solid android:color="#ffffff" />    
<stroke android:width="1dip" android:color="#4fa5d5"/>    
</shape>
于 2012-08-31T06:52:01.273 に答える