AutoCompleteTextView 下拉菜单上的样式 [英] Style on AutoCompleteTextView dropdown

查看:36
本文介绍了AutoCompleteTextView 下拉菜单上的样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一段时间以来,我一直在尝试为自动完成设置下拉列表的样式.目前它看起来像这样:

I've been trying to set the style of my dropdown for the autocomplete for some time now. At the moment it looks like this:

绿色区域是带有备选方案的下拉菜单.我想让那个盒子更小,因为我的圆角矩形目前看起来不太好.

The green area is the dropdown with alternatives. I would like to make that box smaller, since it does'nt look very good at the moment with my rounded rectangle.

我如何实现这一目标?到目前为止,我只能调整其中的每一行..

How do i achieve this? So far I have only been able to adjust each line in it..

推荐答案

在提出问题 5 分钟后发现自己.我会继续为可能遇到此问题的人提出问题.

Found out myself 5 minutes after putting the question here. I'll keep the question up for someone who might come across this.

您可以在创建自动完成文本视图时简单地放置下拉属性.

You can simply put dropdown attributes when you create the autocompletetextview.

android:dropDownWidth="yourWidth"

找不到任何用于设置下拉背景资源的 xml 属性,但编程方式工作正常:

Coudln't find any xml attribute for setting dropdown backgroundresource but the programmatical way works fine:

autoTextView.setDropDownBackgroundDrawable(this.getResources().getDrawable(R.drawable.rounded_rectangle));

通过这种方式,您可以使用自己的可绘制对象定义下拉列表的外观.如果您想使用资源中的 xml 更改它,这是一种方法:

This way you can define how the dropdown should look with your own drawable. If you would want to change it with xml from resource, this is an approach:

android:completionHintView="@layout/your_layout"

这篇关于AutoCompleteTextView 下拉菜单上的样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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