Change thickness of the bottom line of EditText when wrapped into TextInputLayout(包装到 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 底线的粗细的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:包装到 TextInputLayout 时更改 EditText 底线的粗细


- 想使用ViewPager,无法识别android.support.*? 2022-01-01
- Android - 拆分 Drawable 2022-01-01
- android 4中的android RadioButton问题 2022-01-01
- 使用自定义动画时在 iOS9 上忽略 edgesForExtendedLayout 2022-01-01
- 用 Swift 实现 UITextFieldDelegate 2022-01-01
- 如何检查发送到 Android 应用程序的 Firebase 消息的传递状态? 2022-01-01
- MalformedJsonException:在第1行第1列路径中使用JsonReader.setLenient(True)接受格式错误的JSON 2022-01-01
- 在测试浓缩咖啡时,Android设备不会在屏幕上启动活动 2022-01-01
- Android viewpager检测滑动超出范围 2022-01-01
- Android - 我如何找出用户有多少未读电子邮件? 2022-01-01