2013-11-23 2 views
1

Привет всем Я всего лишь несколько дней опыта в android, learning .. Я пытаюсь создать приложение, которое использует темы, но перед проблемой стоит надеяться, что вы могли бы мне помочь.Создание новой темы в Android

Это мой Компоновка

<CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@android:id/text1" 
android:layout_width="match_parent" 
android:layout_height="wrap_content" 
android:gravity="center_vertical" 
android:checkMark="?android:attr/textCheckMark" 
android:paddingStart="10dp" 
android:paddingEnd="10dp" 
style="?TextColor" 
/> 

Это мой style.xml

<!-- GENERIC STYLES --> 
    <style name="App_text_color_white" parent="android:Theme"> 
     <item name="android:textColor">@color/White</item> 
    </style> 
    <style name="App_text_color_black" parent="android:Theme"> 
     <item name="android:textColor">@color/Black</item> 
    </style> 

<!-- RED Theme Styles ####################################### --> 
    <style name="App_Bg_img_red" parent="android:Theme"> 
     <item name="android:background">@drawable/red_abstract_background_blur</item> 
    </style> 

<!-- RED Theme --> 
    <style name="NoteItTheme.RED"> 
     <item name="pageBackgroundImage">@style/App_Bg_img_red</item> 
     <item name="TextColor">@style/App_text_color_black</item> 
    </style> 

Ниже мой attr.xml

<resources> 
    <!-- View styles --> 
    <attr name="pageBackgroundImage" format="reference" /> 
    <attr name="TextColor" format="reference" /> 
</resources> 

Я устанавливаю тему в onCreate метода, используя следующий код

this.setTheme(R.style.NoteItTheme_RED); 

Теперь проблема в настройке фонового изображения прекрасна, что означает, что тема работает. Но я TextColor не меняет его всегда белый, с или без применения темы.

Любая идея, что не так в моем коде?

Заранее спасибо здесь скриншот

К сожалению, я забыл упомянуть: фоновое изображение устанавливается для корневого RelativeLayout и TextColor Я хочу, чтобы установить это для ListView Проверив TextBox

here is the screenshot

ответ

0

вы должны использовать

<style name="image" parent="@android:style/Widget.ImageButton"> 
    <item name="android:background">#000000 <!-use your selector for image buttons --></item> 
</style> 

в файле стилей для фона imagebuttons и следующий код для TextViews

<style name="text" parent="@android:style/Widget.TextView" > 
    <item name="android:textColor"><!-use your textcolor --></item>  
</style> 

редактировать

<style name="NoteItTheme.RED"> 
      <item name="pageBackgroundImage">@style/App_Bg_img_red</item> 
      <item name="TextColor">@style/App_text_color_black</item> 
      <item name="android:imageButtonStyle">@style/image</item> 
<item name="android:textViewStyle">@style/text</item> 
     </style> 
0

Попробуйте это,

<!-- RED Theme --> 
<style name="NoteItTheme.RED"> 
    <item name="pageBackgroundImage">@style/App_Bg_img_red</item> 
    <item name="android:textViewStyle">@style/App_text_color_black</item>  
</style> 

<style name="App_text_color_black" parent="@android:style/Widget.TextView" > 
    <item name="android:textColor">@color/Black</item>  
</style> 
Смежные вопросы