android - 如何更改TextInputLayout内edittext的边框颜色
问题描述
我在edittext周围使用TextInputLayout。我想更改 TextInputLayout 中存在的编辑文本的边框颜色。
xml
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.TextInputEditText
android:id="@+id/Test1"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</android.support.design.widget.TextInputLayout>
夏普
private TextInputEditText editor;
editor = FindViewById<TextInputEditText>(Resource.Id.Test6);
editor.Background.SetColorFilter(Android.Graphics.Color.Red, Android.Graphics.PorterDuff.Mode.SrcAtop);
如果 TextInputLayout 中不存在编辑文本,则上述代码可以正常工作。只有在 TextInputLayout 中使用 edittext 时才会出现问题。我怎样才能解决这个问题?
解决方案
在可绘制文件夹中创建可绘制文件,即drawable_name.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Background Color -->
<solid android:color="#ffffff" />
<!-- Border Color -->
<stroke android:width="1dp" android:color="#e7e7e7e7" />
<!-- Round Corners -->
<corners android:radius="5dp" />
</shape>
并将这个drawable设置为edittext
drawble = "@drawable/drawble_name"
根据您的要求更改边框颜色
推荐阅读
- javascript - ....js的标题
- angular - 如何在全球范围内更改 mat-datepicker 的输出?
- flutter - 使用 google_maps_flutter 时接受位置权限后我的位置按钮未显示?
- c# - Windows 10 上 C# 中的智能卡
- java - Java 常量继承
- python - PyQt4_如何从MainWindow返回LoginWindow?
- google-apps-script - 如何获取表格宽度
- objective-c - 点击消息应用时 UIActivityController 崩溃
- sql - 返回找到的任何单词的 SQL 查询
- .net - .Net Core API 相同的 url 不同的租户有效负载