我創建了一個按鈕樣式定義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將按鈕包含到不同的布局中。
樣式從未應用
知道為什么嗎?
uj5u.com熱心網友回復:
你必須更新你的根主題父而不是Button父
<style name="AppTheme" parent="Theme.MaterialComponents.NoActionBar.Bridge">
</?


uj5u.com熱心網友回復:
您需要使用 AppCompatbutton。然后,您可以應用樣式。
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/457378.html
