Android set edit text style globally in theme doesn't work

后端 未结 5 891
我寻月下人不归
我寻月下人不归 2020-12-16 11:30

I am facing with problem. I am trying to make edit texts in my app look the same with the help of theme.
I have generated styles with the help of online tools (9-patch i

相关标签:
5条回答
  • 2020-12-16 11:44

    In addition to fixing the reference to the Widget.EditText:

    <style name="EditTextDefault" parent="@android:style/Widget.EditText">
    

    You need to create a "theme" and apply it in your manifest. Like this:

    <application
        ...
        android:theme="@android:style/DefaultAppTheme" >
    </application>
    
    0 讨论(0)
  • 2020-12-16 11:46

    if your are using appcompat >v22 you can try using

    <style name="EditText.Colored" parent="Theme.AppCompat">
        <item name="colorControlNormal">@color/colorNormal</item>
        <item name="colorControlActivated">@color/colorActivated</item>
        <item name="colorControlHighlight">@color/colorControlHighlight</item>
    </style>
    

    and in your layout.xml set the android:theme propertie to the edittext

    <EditText
        android:id="@+id/edit_text_login"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_above="@+id/edit_text_password"
        android:theme="@style/EditText.Colored"
        android:hint="@string/hint_enter_login"
        android:inputType="textEmailAddress" />
    
    0 讨论(0)
  • 2020-12-16 11:50

    What Should You Do

    Use this @android:style/Widget.EditText instead parent="android:Widget.EditText" .I hope it will helps you .

    Please read This SO Answer Set a consistent style to all EditText

    <style name="EditTextDefault" parent="@android:style/Widget.EditText">
    
    0 讨论(0)
  • 2020-12-16 11:52

    instead of this..

    <item name="android:editTextStyle">@style/EditTextDefault</item>
    

    use this..

    <item name="editTextStyle">@style/EditTextDefault</item>
    
    0 讨论(0)
  • 2020-12-16 12:03

    Use your style.xml To get Good theme with cursor lite

    <resources>
    
        <!-- Base application theme. -->
        <style name="AppTheme" parent="android:style/Theme.Holo.Light">
            <!-- Customize your theme here. -->
        </style>
    
        <style name="NoActionBar" parent="android:style/Theme.Holo.Light.NoActionBar">
            <!-- Customize your theme here. -->
        </style>
    
        <style name="FullScreen" parent="android:style/Theme.Holo.Light.NoActionBar.Fullscreen">
            <!-- Customize your theme here. -->
        </style>
    </resources>
    

    Add this in your Style.xml

    If this answer is not satisfied you can edit or ask me for delete

    0 讨论(0)
提交回复
热议问题