设置AutoCompleteTextView分隔线的高度在android中无效 [英] Setting AutoCompleteTextView divider height has no effect in android

查看:150
本文介绍了设置AutoCompleteTextView分隔线的高度在android中无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的AutoCompleteTextView

Here is my AutoCompleteTextView

<AutoCompleteTextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:dividerHeight="4dp"
        android:gravity="center"
        android:inputType="textCapWords|textAutoCorrect"
        android:textColor="@color/font_autocomplete"
        android:textSize="18sp" />

有人知道为什么设置android:dividerHeight无效吗?

Does anyone know why setting the android:dividerHeight has no effect?

推荐答案

AutoCompleteTextView是复合视图-它既有EditText组件又有浮动的DropDown组件. EditText组件的样式很简单,但是DropDown却很困难,因为它是AutoCompleteTextView本身的属性和通过android:dropDownListViewStyle在主题中设置的样式的混合.

An AutoCompleteTextView is a compound View - it's got both an EditText component and a floating DropDown component. The EditText component is straightforward to style, but the DropDown is difficult because it's a mixture of attributes on the AutoCompleteTextView itself and styles set in the theme via android:dropDownListViewStyle.

如果要更改分隔线,则必须创建一个主题并将其指向一种样式,这并不是立即显而易见的解决方案:

If you want to change the dividers, you have to create a theme and point that to a style, which isn't an immediately obvious solution:

<style name="MyTheme">
  <item name="android:dropDownListViewStyle">@style/DropDownListViewStyle</item>
</style>

<style name="DropDownListViewStyle">
  <item name="android:dividerHeight">4dp</item>
</style>

但是请注意,这些样式更改将应用​​于整个Application.因此,如果您的UI中还有其他DropDown组件,它们也可能也会受到影响.

Note, however, that these style changes will apply across your whole Application. So if you've got other DropDown components in your UI, they'll likely be affected as well.

这篇关于设置AutoCompleteTextView分隔线的高度在android中无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆