【发布时间】:2016-05-24 10:47:05
【问题描述】:
我有一个对话框布局,其中我有 3 个编辑文本,对于第一个编辑文本,它显示下划线颜色为绿色(原色),而其他两个编辑文本显示颜色为粉红色(重音)。
为什么会这样?它应该与其他两个编辑文本相同。
试图改变这个:
name.getBackground().mutate().setColorFilter(getResources().getColor(R.color.colorAccent), PorterDuff.Mode.SRC_ATOP);
name.getBackground().setColorFilter(getResources().getColor(R.color.colorAccent), PorterDuff.Mode.SRC_ATOP);
也由 SO 解决方案。但没有任何帮助。
<style name="AppBaseTheme" parent="Theme.AppCompat.Light">
....
<item name="android:editTextStyle">@style/EditTextStyle</item>
</style>
<style name="EditTextStyle" parent="Widget.AppCompat.EditText">
<item name="colorControlNormal">@color/border_gray</item>
<item name="colorControlActivated">@color/border_gray</item>
<item name="colorControlHighlight">@color/border_gray</item>
</style>
布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical">
<LinearLayout android:layout_height="50dp"
android:layout_width="match_parent"
android:background="@color/colorPrimary">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Add Schedule"
android:textColor="@android:color/white"
android:textAppearance="@android:style/TextAppearance.Medium"
android:layout_gravity="center"
android:layout_marginLeft="20dp" />
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="20dp">
<EditText
android:id="@+id/edt_name"
android:layout_width="match_parent"
android:layout_height="45dp"
android:textColor="#000000"
android:textSize="14sp"
android:inputType="textCapSentences"
android:hint="Name"
android:cursorVisible="false"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="20dp" />
<EditText
android:id="@+id/edt_dateTime"
android:layout_width="match_parent"
android:layout_height="45dp"
android:textColor="#000000"
android:textSize="14sp"
android:cursorVisible="false"
android:inputType="textCapSentences"
android:hint="Date and Time"
android:layout_centerVertical="true"
android:layout_alignLeft="@+id/edt_name"
android:layout_alignStart="@+id/edt_name"
android:layout_below="@+id/edt_name"
android:layout_alignRight="@+id/edt_name"
android:layout_alignEnd="@+id/edt_name"
android:layout_marginTop="05dp" />
<EditText
android:id="@+id/edt_budget"
android:layout_width="match_parent"
android:layout_height="45dp"
android:textColor="#000000"
android:textSize="14sp"
android:cursorVisible="false"
android:hint="Budget"
android:layout_below="@+id/edt_dateTime"
android:layout_alignLeft="@+id/edt_dateTime"
android:layout_alignStart="@+id/edt_dateTime"
android:layout_alignRight="@+id/edt_dateTime"
android:layout_alignEnd="@+id/edt_dateTime"
android:layout_marginTop="05dp"
android:inputType="number" />
</RelativeLayout>
</LinearLayout>
这是我实现drawable后得到的。
谢谢你..
【问题讨论】:
-
您可以参考我之前的answer 并根据需要删除dashgap或stroke。
-
但是为什么会这样呢?为什么只用于第一个编辑文本和其他两个?如果我不想使用drawable? @SathishKumarJ
-
但是为什么会这样呢?为什么只用于第一个编辑文本和其他两个?如果我不想使用drawable? @ShreeKrishna
-
@user6265109 试试我的回答并告诉我状态
标签: android colors android-edittext