2012-09-02 36 views

回答

0
<?xml version="1.0" encoding="utf-8"?> 
    <resources> 
    <style name="black_text_view_medium" parent="@android:style/TextAppearance.Medium"> 
      <item name="android:textColor">@color/black</item> 
      <item name="android:typeface">normal</item> 
      <item name="android:textSize">16sp</item> 
     </style> 
    </resources> 

這是在res/values/red.xml中創建的資源文件,並在您的textview中像這樣定義此樣式。

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    > 
<TextView 
    style="@style/black_text_view_medium" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="This is your Textview Style" 
    /> 
</LinearLayout> 
1

試試這個代碼,

shape.xml(保存此在res /抽拉/)

<selector xmlns:android="http://schemas.android.com/apk/res/android"> 
<item>   
<shape> 
    <corners android:radius="3dp/> 
</shape> 
</item> 
</selector> 

然後改變的TextView的背景。

<TextView 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:background="@drawable/shape" /> 
相關問題