android - AutoCompleteTextView 设置高度以填充父级
问题描述
我是 Android 开发的新手,自己学习!我只想将我的 AutoCompleteTextView 下拉高度设置为填充父级。
我在 XML 中的 AutoCompleteTextView 视图是:
<AutoCompleteTextView
android:id="@+id/countries_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="@dimen/_20sdp"
android:dropDownHeight="match_parent"
android:ems="10">
</AutoCompleteTextView>
我还附上了一个屏幕截图,显示下拉列表的绿色部分仅填充父项的一部分,但我希望它按其高度填充父项。不知道有没有可能?有人能找出我的可能性吗?
有关额外信息,我将在此处添加完整的布局:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<AutoCompleteTextView
android:id="@+id/countries_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="@dimen/_20sdp"
android:dropDownHeight="match_parent"
android:ems="10">
</AutoCompleteTextView>
<RelativeLayout
android:id="@+id/revealLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="?android:attr/actionBarSize"
android:animateLayoutChanges="true"
android:background="#00FFA9"
android:visibility="gone">
<TextView
android:id="@+id/textReveal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="Hello Reveal!"
android:textColor="#000000"
android:textSize="@dimen/_24ssp"/>
</RelativeLayout>
</RelativeLayout>
解决方案
如果您正在使用,android:dropDownHeight="match_parent"
那么它将在 API 8 之后工作,而不是更少。除非您输入固定值,例如 200dp 或 300dp。
推荐阅读
- azure-sql-database - How to deploy Azure SQL database via service principal
- angular - Build error after updated Angular to 6.1 from 5.2 in view.d.ts
- html - HTML Canvas not showing on Safari
- notifications - GCP Auto-scaling alert
- ios - CocoaLumberjack - Swift : Deleting Old Logs all of sudden
- python - Extracting specific values to sheets of the same name Python
- ruby-on-rails - 通过签名验证 Shipwire Webhook
- postgresql - postgres 中的 To_char(text) 函数
- jmeter - 将 JTL 文件导入 JMeter GUI 时读取 JTL 文件时出现问题
- javascript - 检测点击 youtube iframe javascript