【问题标题】:Android TextView stylesAndroid TextView 样式
【发布时间】:2013-02-26 11:29:29
【问题描述】:

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

【问题讨论】:

    标签: android android-layout android-ui android-theme


    【解决方案1】:

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

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

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

    【讨论】:

      猜你喜欢
      • 2016-07-02
      • 1970-01-01
      • 2016-07-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-04-05
      • 1970-01-01
      • 2014-04-08
      相关资源
      最近更新 更多