android - 单击 Spinner1 而不是覆盖在第二个和第三个微调器上
问题描述
单击微调器时,我希望下拉列表不要覆盖在第二个微调器上。而不是第二个微调器应该在下拉列表下方。需要帮助谢谢!
我的微调器 xml 代码
<Spinner
android:id="@+id/spinner1"
style="@style/Widget.AppCompat.Spinner"
android:layout_width="match_parent"
android:layout_height="?attr/dropdownListPreferredItemHeight"
android:dropDownSelector="@drawable/ic_dropdown"
android:background="@drawable/spinner_bg"
android:dropDownWidth="match_parent"
android:dropDownVerticalOffset="?attr/dropdownListPreferredItemHeight"
android:popupBackground="@android:color/white"
android:popupElevation="3dp"
android:stateListAnimator="@drawable/spinner_sla"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Spinner
android:id="@+id/spinner2"
android:layout_marginTop="2dp"
android:layout_width="match_parent"
android:layout_height="50dp"
android:dropDownVerticalOffset="40dp"
android:spinnerMode="dropdown"
android:entries="@array/country_arrays"
android:prompt="@string/country_prompt"/>
<Spinner
android:id="@+id/spinner3"
android:layout_marginTop="2dp"
android:layout_width="match_parent"
android:layout_height="50dp"
android:spinnerMode="dropdown" />
解决方案
我建议您使用 ExpandableListView,因为它可以让您下推内容。
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<ExpandableListView
android:id="@+id/lvExp"
android:layout_height="match_parent"
android:layout_width="match_parent"/>
</LinearLayout>
举一个完整的例子,我在Github上上传了一个工作项目
推荐阅读
- swift - SwiftUI 表单中的选取器在选择一个值后变为灰色
- javascript - Javascript用函数替换字符串
- angular - Angular Universal 没有在客户端重新补水 DOM 节点
- python - 队列的正确类结构是什么
- spring-boot - Jackson 不会自动将复杂的字段名称从 json-object 转换为 dto-object
- mysql - SQL 查询:[计算查询结果]
- mqtt - 寻找“现成的裸机 MQTT 代理”
- java - 如何从 MongoCollection 获取实际查询?
- delphi - 退出正在编辑的单元格时如何在 TDBgrid 中立即发布数据
- python - 如何在matplotlib中的圆上均匀分布点?