Android TextView样式

Vin*_*mar 3 android android-ui android-layout android-theme

我正在尝试为TextView控件设置样式.我可以添加用户定义的样式或系统样式.但我不能为我的TextView设置两者.我想显示像按钮样式的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>
Run Code Online (Sandbox Code Playgroud)

我的style.xml代码是:

<style name="transactionbtn">
    <item name="android:width">140dp</item>
    <item name="android:height">45dp</item>
    <-- How to add button style here -->
</style>
Run Code Online (Sandbox Code Playgroud)

Mat*_*ers 6

您的样式可以继承另一种样式,例如Android资源中的样式.

    <style name="Button" parent="@android:style/Widget.Button">
        .
        .
        .
    </style>
Run Code Online (Sandbox Code Playgroud)

将父级更改@android:style/Widget.Holo.Button为Holo样式.