Kotlin不应用样式
我在 themes.xml
中创建了一个按钮样式定义,如下所示:
<style name="MyAppTheme.Button" parent="Widget.AppCompat.Button.Colored">
<item name="android:textSize">16sp</item>
<item name="android:letterSpacing">0.06</item>
<item name="android:textColor">@color/white</item>
<item name="android:background">@color/brand04</item>
</style>
我按如下方式应用它:
<layout xmlns:android="http://schemas.android.com/apk/res/android">
<data>
<variable name="text" type="String"/>
</data>
<Button
android:theme="@style/MyAppTheme.Button"
android:id="@+id/button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:focusable="true"
android:enabled="true"
android:letterSpacing="0.5"
android:paddingTop="25dp"
android:paddingBottom="25dp"
android:text="@{text}"/>
</layout>
我使用 include
将按钮包含到不同的布局中。
这种风格从未被应用过,
知道为什么吗?
I have created a button style defines in the themes.xml
as below:
<style name="MyAppTheme.Button" parent="Widget.AppCompat.Button.Colored">
<item name="android:textSize">16sp</item>
<item name="android:letterSpacing">0.06</item>
<item name="android:textColor">@color/white</item>
<item name="android:background">@color/brand04</item>
</style>
I apply it as followed:
<layout xmlns:android="http://schemas.android.com/apk/res/android">
<data>
<variable name="text" type="String"/>
</data>
<Button
android:theme="@style/MyAppTheme.Button"
android:id="@+id/button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:focusable="true"
android:enabled="true"
android:letterSpacing="0.5"
android:paddingTop="25dp"
android:paddingBottom="25dp"
android:text="@{text}"/>
</layout>
I am using include
to include the button into different layout.
The style is never applied
any idea why ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您必须更新词根主题父,而不是
按钮
parenthttps://i.sstatic.net/sv0y2.png“ alt =” them.xml“>
You have to update your root theme parent not the
Button
parent您需要使用AppCompatbutton。
然后,您可以应用样式。
you need to use AppCompatbutton.
You can then apply style.