テーマと特定のボタン デザインを宣言できます。
<style name="MyTheme" parent="android:style/Theme.Black">
<item name="android:buttonStyle">@style/Button.b1</item>
</style>
<style name="Button.b1" parent="android:style/Widget.Button">
<item name="android:textColor">#000000</item>
</style>
問題は、このスタイルがすべてのボタンに適用されることです。他のボタン (「保存」ボタンのようなもの) とは独立して各テーマを変更する独自のスタイルで特定のボタンを宣言したいと思います。何か案が?
私は次のことを試しました:
<style name="Button.MyButton" parent="android:style/Widget.Button">
<item name="android:background">@drawable/shape</item>
</style>
<style name ="Button.MyButton.Theme1">
<item name="android:textColor">#000000</item>
</style>
<style name ="Button.MyButton.Theme2">
<item name="android:textColor">#FFFFFF</item>
</style>
<Button
android:id="@+id/save_button"
android:layout_width="0px"
style="@style/Button.MyButton"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="@string/save"/>
これでボタンはテーマから独立しましたが、上で宣言したスタイル属性も適用する必要があります。現時点では、MyButton スコープで宣言されている属性のみが適用され、MyButton.Theme1 または MyButton.Theme2 では適用されません。