本文介紹了包裝到 TextInputLayout 時更改 EditText 底線的粗細的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
這是我的代碼
XML 標記
(聚焦視圖)
現在我的問題/問題
- 我希望底線更薄.我應該在哪里改變它.
- 閃爍的光標不顯示,如何顯示.
- EditText 會自動突出顯示拼寫錯誤.我需要阻止它.
誰能指出解決問題的正確方法.評論你任何人都需要更多信息來回答這個問題.
提前致謝.
解決方案 我已經使用我的自定義 xml drawable 解決了我的問題.可能有更好的方法,但我找不到.以下是我用作文本框背景的可繪制對象
<?xml version="1.0" encoding="utf-8"?><選擇器xmlns:android="http://schemas.android.com/apk/res/android"><項目 android:state_pressed="true"><層列表><項目機器人:底部=1dp"機器人:左=-2dp"機器人:右=-2dp"android:top="-2dp"><形狀 android:shape="矩形"><中風安卓:寬度=0.5dp"android:color="@color/primaryColor"/><solid android:color="#00FFFFFF"/><填充 android:left="3dp"機器人:右=3dp"機器人:頂部=3dp"android:bottom="3dp"/></形狀></項目></層列表></項目><項目 android:state_focused="true"><層列表><項目機器人:底部=1dp"機器人:左=-2dp"機器人:右=-2dp"android:top="-2dp"><形狀 android:shape="矩形"><中風安卓:寬度=0.5dp"android:color="@color/primaryColor"/><solid android:color="#00FFFFFF"/><填充 android:left="3dp"機器人:右=3dp"機器人:頂部=3dp"android:bottom="3dp"/></形狀></項目></層列表></項目><項目><層列表><項目機器人:底部=1dp"機器人:左=-2dp"機器人:右=-2dp"android:top="-2dp"><形狀 android:shape="矩形"><中風安卓:寬度=0.5dp"android:color="#BCBCBC"/><solid android:color="#00FFFFFF"/><填充 android:left="3dp"機器人:右=3dp"機器人:頂部=3dp"android:bottom="3dp"/></形狀></項目></層列表></項目></選擇器>
here is my code
XML Markup
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/TextLabel">
<EditText
android:id="@+id/etContactName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Contact Name"/>
</android.support.design.widget.TextInputLayout>
Style
<style name="TextLabel" parent="TextAppearance.AppCompat">
<item name="android:textColorHint">@color/hintColor</item>
<item name="colorAccent">@color/primaryColor</item>
<item name="colorControlNormal">@color/hintColor</item>
<item name="colorControlActivated">@color/primaryColor</item>
</style>
Here is the output
(normal view)
(focused view)
Now My Problems / Issues
- I want the bottom line to be thinner. where should I change it.
- The blinking cursor is not showing, how to show it.
- EditText is automatically highlighting the spelling mistakes. I need to stop it.
Can anyone please point me to the right way to resolve the issues. Comment you anyone needs more info to answer this.
Thanks in advance.
解決方案 I've solved my issue using my custom xml drawable. There might be some better way, but I couldn't find any. following is my drawable that I'm using as background of my textbox
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
<layer-list >
<item
android:bottom="1dp"
android:left="-2dp"
android:right="-2dp"
android:top="-2dp">
<shape android:shape="rectangle" >
<stroke
android:width="0.5dp"
android:color="@color/primaryColor" />
<solid android:color="#00FFFFFF" />
<padding android:left="3dp"
android:right="3dp"
android:top="3dp"
android:bottom="3dp" />
</shape>
</item>
</layer-list>
</item>
<item android:state_focused="true">
<layer-list >
<item
android:bottom="1dp"
android:left="-2dp"
android:right="-2dp"
android:top="-2dp">
<shape android:shape="rectangle" >
<stroke
android:width="0.5dp"
android:color="@color/primaryColor" />
<solid android:color="#00FFFFFF" />
<padding android:left="3dp"
android:right="3dp"
android:top="3dp"
android:bottom="3dp" />
</shape>
</item>
</layer-list>
</item>
<item>
<layer-list >
<item
android:bottom="1dp"
android:left="-2dp"
android:right="-2dp"
android:top="-2dp">
<shape android:shape="rectangle" >
<stroke
android:width="0.5dp"
android:color="#BCBCBC" />
<solid android:color="#00FFFFFF" />
<padding android:left="3dp"
android:right="3dp"
android:top="3dp"
android:bottom="3dp" />
</shape>
</item>
</layer-list>
</item>
</selector>
這篇關于包裝到 TextInputLayout 時更改 EditText 底線的粗細的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!