【问题标题】:Button theme and style can not apply in adapter按钮主题和样式不能应用于适配器
【发布时间】:2017-04-20 13:14:08
【问题描述】:

按钮主题如下:

<style name="ButtonTheme" parent="Base.Widget.AppCompat.Button">
    <item name="colorButtonNormal">#00c4a9</item>
    <item name="android:textColor">#ffffff</item>
    <item name="android:textSize">@dimen/user_button_size</item>
</style>

按钮代码为:

<Button
    android:id="@+id/bt_exchange"
    style="@style/Widget.AppCompat.Button"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="center_horizontal"
    android:layout_marginLeft="@dimen/normal_margin_32"
    android:layout_marginRight="@dimen/normal_margin_32"
    android:layout_marginTop="@dimen/normal_margin_16"
    android:gravity="center"
    android:text="@string/integral_exchange_goods"
    android:theme="@style/ButtonTheme" />

activity layout中的代码可以应用,但是listview item中的代码,主题和样式不能应用时,activity扩展了AppCompatActivity。
感谢日志。

【问题讨论】:

    标签: android button styles themes


    【解决方案1】:

    据我所知,您没有应用正确的样式。您的样式名称是ButtonTheme,它从Base.Widget.AppCompat.Button 扩展而来,但您将@style/Widget.AppCompat.Button 作为您的样式,用于标识为bt_exchangeButton

    我认为你应该改用@style/ButtonTheme

    【讨论】:

    • @style/ButtonTheme 不生效,代码可以应用在activity布局中。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-05-13
    • 1970-01-01
    • 1970-01-01
    • 2015-11-04
    • 1970-01-01
    • 1970-01-01
    • 2020-10-17
    相关资源
    最近更新 更多