【发布时间】:2018-08-04 15:45:52
【问题描述】:
我想将自定义AutoCompleteTextView的下划线颜色更改为下面电话号码下的蓝色为其他颜色,并去除下划线上方约2dp的空间(请注意垂直线两端)。
我在网上找不到问题的解决方案。
在创建自定义 AutoCompleteTextView 之前,我通过如下所示的 colors.xml 上的重音更改了内置 AutoCompleteTextView 的下划线颜色。
<resources>
...
<color name="accent">#206DDA</color>
...
</resources>
但是,在使用自定义AutoCompleteTextView 代替内置AutoCompleteTextView 后,下划线颜色将使用默认颜色,如上图。
我在下面尝试过,但它不起作用: 下面的styles.xml:
<style name="Autocomplete" parent="Widget.AppCompat.Light.AutoCompleteTextView">
<item name="colorControlActivated">@color/primary</item>
</style>
activity.xml 下面:
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<MyAutoCompleteTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Phone number"
android:completionThreshold="1"
android:maxLines="1"
android:inputType="text"
android:imeOptions="actionNext"
android:theme="@style/Autocomplete"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp" />
</android.support.design.widget.TextInputLayout>
下面是我的 AutoCompleteTextView:
public class MyAutoCompleteTextView: AutoCompleteTextView
{
public MyAutoCompleteTextView(Context context, IAttributeSet attrs)
: base(context, attrs)
{
}
public override bool EnoughToFilter()
{
return true;
}
}
【问题讨论】:
-
将主题设置为
TextInputLayout.. 那么删除2dp空间是什么意思??
标签: android xamarin xamarin.android autocompletetextview