2014-12-22 5 views
10

appcompat 라이브러리를 최신 버전 (v21)으로 업데이트하여 재질 디자인을 적용한 후 Android 4.0.X 기기에서 내 맞춤 테마가 더 이상 사용되지 않습니다. XML에서 명시 적으로 선언하십시오.일부 Android 4.X 기기에서 appcompat 라이브러리를 사용하여 테마가 적용되지 않음

Android 2.3.X 및 5.0.0 기기에서 테마를 테스트했으며 해당 기기에서 작동합니다. 하지만 안드로이드 4.0.3과 내 HTC 한 S에서 작동하지 않습니다. 이 문제를 해결하려면 무엇을해야합니까?

내 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> 

내 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> 

내 레이아웃 파일

<?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> 

나는 레이아웃의 행에 다음을 추가하는 경우 파일이 작동합니다. 그래서 themes.xml에 문제가있는 것 같습니다.

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

결과 : 예상

Result

:

Expected

편집

는 좀 다른 장치에 동일한 코드를 테스트했다.

  • 삼성 S2 (4.0.4) OK
  • HTC 온 (4.4.3) OK
  • HTC 한 X (4.0.3) NOK
  • HTC 한 S (4.1.1) : NOK
  • HTC 욕망 C (4.0.3)은 이러한 장치의 일부에 작동하지 않을 이유 NOK

나는 볼 수 없습니다.

답변

0

마지막으로 내 문제에 대한 해결책을 찾았습니다. 내 스타일 중 하나에 부모로 @style/Theme.AppCompat을 사용하고있었습니다. @style/Theme.AppCompat.Light.DarkActionBar으로 변경하면 모든 장치에서 작동합니다. 나는 이것이 왜 내 스타일을 망쳐 놓는 지 매우 이상하다는 것을 알게된다.

+0

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

4

나는 "android :"접두사없이 buttonStyle을 추가하고 문제를 해결했습니다. (이름 = "안드로이드 : buttonStyle"-> 이름 = "buttonStyle")는

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

나를 위해 문제를 해결 . 감사! – Sly