3

我正在尝试为 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>

我的 style.xml 代码是:

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

1 回答 1

6

您的样式可以继承其他样式,例如来自 Android 资源的样式。

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

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

于 2013-02-26T23:49:13.977 回答