2014-12-22 13 views
10

Po zaktualizowaniu biblioteki aplikacji do najnowszej wersji (v21) w celu zastosowania projektu materiału, mój niestandardowy motyw nie jest już używany na urządzeniach z Androidem 4.0.X, chyba że jawnie zadeklaruj to w XML.Motyw nie został zastosowany przy użyciu biblioteki appcompat na niektórych urządzeniach z Androidem 4.X

Przetestowałem ten motyw na urządzeniach z systemem Android 2.3.X i 5.0.0 i działa on na tych urządzeniach. Ale to nie działa na moim HTC One S z Androidem 4.0.3. Co muszę zrobić, aby to naprawić?

Moja themes.xml

<style name="Theme.Custom" parent="@style/Theme.AppCompat.Light"> 
    <item name="android:editTextStyle">@style/Custom.Widget.EditText</item> 
    <item name="android:buttonStyle">@style/Custom.Widget.Button</item> 
</style> 

Moja styles.xml

<style name="Custom.Widget.EditText" parent="android:Widget.EditText"> 
    <item name="android:background">@drawable/edit_text_holo_light</item> 
    <item name="android:textColor">@color/text_primary</item> 
    <item name="android:textColorHint">@color/text_hint_color</item> 
</style> 

<style name="Custom.Widget.Button" parent="android:Widget.Button"> 
    <item name="android:background">@drawable/btn_default_holo_light</item> 
    <item name="android:minHeight">48dip</item> 
    <item name="android:minWidth">64dip</item> 
    <item name="android:textColor">@color/button_text_primary</item> 
</style> 

Mój plik układ

<?xml version="1.0" encoding="utf-8"?> 
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
android:layout_width="match_parent" 
android:layout_height="match_parent" > 

<RelativeLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_gravity="center_horizontal" > 

    <!-- other elements --> 

    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginTop="16dp" 
     android:paddingLeft="16dp" 
     android:paddingRight="16dp" > 

     <EditText 
      android:id="@+id/view_username_edit_username_editText" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:inputType="textNoSuggestions|textCapSentences" 
      android:hint="@string/UsernameScreen_usernameHint" 
      android:imeOptions="actionDone" 
      android:singleLine="true" 
      android:maxLength="@integer/username_max_length" 
      android:textSize="@dimen/text_size_medium" /> 

     <Button 
      android:id="@+id/view_username_save_Button" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_below="@+id/view_username_edit_username_editText" 
      android:clickable="true" 
      android:enabled="false" 
      android:orientation="horizontal" 
      android:text="@string/common_save" /> 
    </RelativeLayout> 

</RelativeLayout> 

Gdybym dodać następujące linie w układzie pliki to działa. Wydaje się, że coś poszło nie tak z plikiem themes.xml.

style="@style/Custom.Widget.EditText" 
style="@style/Custom.Widget.Button" 

Wynik:

Result

Oczekiwany:

Expected

Edit

Przetestowałem ten sam kod na innych urządzeniach.

  • Samsung S2 (4.0.4) OK
  • HTC One (4.4.3) OK
  • HTC One X (4.0.3) NOK
  • HTC One S (4.1.1): NOK
  • HTC Desire C (4.0.3): NOK

nie widzę, dlaczego to nie działa na niektórych z tych urządzeń.

Odpowiedz

0

W końcu znalazłem rozwiązanie mojego problemu. Używałem @style/Theme.AppCompat jako rodzica do jednego z moich stylów. Po zmianie na @style/Theme.AppCompat.Light.DarkActionBar działa na wszystkich urządzeniach. Nadal uważam, że to bardzo dziwne, dlaczego to zepsułoby mój styl.

+0

https://code.google.com/p/android/issues/detail?id=78819 – ADK

4

Po dodaniu przycisku buttonStyle bez prefiksu "android:" rozwiązało problem. (name = "android: ButtonStyle" -> name = "ButtonStyle")

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> 
    <item name="buttonStyle">@style/SkinedButton</item> 
</style> 
+0

rozwiązany problem dla mnie . DZIĘKI! – Sly

Powiązane problemy