I make material design style application
I want to change AutoCompleteTextView
style
to style like in android.support.v7.internal.widget.TintEditText
I added style to my style.xml:
<style name="AppTheme" parent="AppTheme.Base"/>
<style name="AppTheme.Base" parent="Theme.AppCompat">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="android:autoCompleteTextViewStyle">@style/AutoCompleteTextViewAppTheme</item>
</style>
<style name="AutoCompleteTextViewAppTheme" parent="Base.Widget.AppCompat.EditText"/>
That works but the line colors does not change.
EditTexts with material design seem to use colorControlActivated
and colorControlNormal
. Therefore, I have tried to override these properties in the previous style definition but it has no effect.
What I need to do, to make it work ?
Android AutoCompleteTextView OverviewgetAdapter() : This method returns a filterable list adapter used for auto completion.
XML attributes Defines the number of characters that the user must type before completion suggestions are displayed in a drop down menu.
In android, we can create an AutoCompleteTextView control in two ways either manually in an XML file or create it in the Activity file programmatically. First we create a new project by following the below steps: Click on File, then New => New Project. After that include the Kotlin support and click on next.
If you want to get suggestions , when you type in an editable text field , you can do this via AutoCompleteTextView. It provides suggestions automatically when the user is typing. The list of suggestions is displayed in a drop down menu from which the user can choose an item to replace the content of the edit box with.
Try to add the desired style to use for your widget in the xml this way :
<View
style="@style/NameOfYourTheme"
...
/>
If that doesn't work you could try to style it yourself. You will have to change the TextView attributes which you can look up here.
Textcolor for an instance could be changed by changing the android:textColor
attribute which should be added to your style, for example :
<style name="AutoCompleteTextViewAppTheme" parent="Base.Widget.AppCompat.EditText"/>
<item name="android:textColor">#ffffffff</item>
</style>
If you want to change the edittext line you have to change the background attribute, for example in this manner :
<item name ="android:background="@drawable/line_background"> </item>
And add a new file line_background.xml
in your drawables folder with a similar content:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="line">
<stroke
android:color="#c0c000"
android:width="3dp"></stroke>
</shape>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With