2013-02-26 59 views
3

我想爲TextView控件設置樣式。我能夠添加用戶定義的樣式或系統樣式。但是我不能爲我的TextView設置這兩個選項。我想像按鈕樣式顯示TextView,我必須添加寬度和高度。 我的佈局代碼:Android的TextView風格

<TextView 
    android:id="@+id/trans_payable" 
    <-- style="@android:style/Widget.Button" --> 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_gravity="left" 
    android:clickable="true" 
    android:paddingLeft="10sp" 
    android:paddingTop="20sp" 
    android:paddingRight="50sp" 
    style="@style/transactionbtn" 
    android:text="@string/trans_payable" > 
</TextView> 

而且我style.xml代碼:

<style name="transactionbtn"> 
    <item name="android:width">140dp</item> 
    <item name="android:height">45dp</item> 
    <-- How to add button style here --> 
</style> 

回答

5

你的風格可以繼承另一種風格,例如來自Android資源的風格。

<style name="Button" parent="@android:style/Widget.Button"> 
     . 
     . 
     . 
    </style> 

將父母更改爲全息風格的@android:style/Widget.Holo.Button

+0

非常感謝你matthias它的工作以及我所期望的。 – 2013-02-27 04:58:43