Как осуществить стилизацию приложения в android?

Как сделать два стиля кнопок, которые зависят от выбранной темы?
Для одной кнопки тут всё понятно:
<!-- Тема по умолчанию -->
    <style name="DefaultTheme" parent="@style/_DefaultTheme"/>
    <style name="_DefaultTheme" parent="android:Theme.Light">       
        <item name="android:buttonStyle">@style/ButtonDefaultTheme</item>
   </style>
   <!-- Стиль кнопок по умолчанию -->
  <style name="ButtonDefaultTheme" parent="android:Widget.Button">
	  <item name="android:background">@drawable/defaulttheme_btn_default_holo_light</item>
	  <item name="android:minHeight">48dip</item>
	  <item name="android:minWidth">64dip</item>
	  <item name="android:textColor">#000000</item>
  </style>


Но как сделать два стиля кнопок в одной теме?
  • Вопрос задан
  • 4630 просмотров
Пригласить эксперта
Ответы на вопрос 1
@Sp0tted_0wl
А почему бы не определить различные стили и уже потом вешать их на кнопки?
Например так:
<style name="WhiteButtonStyle" parent="@android:style/Widget.Button">
    <item name="android:textColor">@android:color/white</item>
</style>
<style name="RedButtonStyle" parent="@android:style/Widget.Button">
    <item name="android:textColor">@android:color/red</item>
</style>


<Button
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:text="StyleWhite"
        style="@style/WhiteButtonStyle" />
<Button
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:text="StyleRed"
        style="@style/RedButtonStyle" />
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы