这是我的代码
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模板网!
EditText:禁用文本选择处理程序单击事件上的粘贴EditText: Disable Paste/Replace menu pop-up on Text Selection Handler click event(EditText:禁用文本选择处理程序单击事件上的粘贴/替换菜
2.3 上带有完成 SoftInput 操作标签的多行 EditTextMultiline EditText with Done SoftInput Action Label on 2.3(2.3 上带有完成 SoftInput 操作标签的多行 EditText)
如何在 Android 中检测向左或向右滑动?How to detect the swipe left or Right in Android?(如何在 Android 中检测向左或向右滑动?)
防止在Android中的屏幕旋转对话框解除Prevent dialog dismissal on screen rotation in Android(防止在Android中的屏幕旋转对话框解除)
如何处理 ImeOptions 的完成按钮点击?How do I handle ImeOptions#39; done button click?(如何处理 ImeOptions 的完成按钮点击?)
您如何将 EditText 设置为仅接受 Android 中的数值How do you set EditText to only accept numeric values in Android?(您如何将 EditText 设置为仅接受 Android 中的数值?)