【发布时间】:2016-05-29 12:35:15
【问题描述】:
我有这个代码 xml 布局,我试图在圆形 android 磨损手表中实现。我希望ExpandableListView 上方的TextView 与它一起滚动,而不是停留在顶部并占用空间。
我尝试使用ScrollView 而不是RelativeLayout(ScrollView 在RelativeLayout 中,反之亦然)但是这样做是LinearLayout 需要为ExpandableListView 设置一个高度显示由于列表动态变化而不可能的列表(因此它可以具有随机数量的组成员),如果我使用“wrap_content”,它一次只显示一个组。每个组也有 4 个子成员。
谁能告诉我如何使这个布局适合我,以便TextView 和ExpandableListAdapter 一起滚动,而无需为ExpandableListAdapter 设置高度?
round_activity_card_view_layout.xml
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
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="com.jawad.wifihotspotfinder.CardViewLayout"
tools:deviceIds="wear_round"
android:background="#FF3C00"
android:smoothScrollbar="true">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingTop="20dp"
android:paddingLeft="15dp"
android:paddingRight="10dp"
android:paddingBottom="10dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/cardViewHeader"
android:textSize="17sp"
android:textColor="@color/white"
android:fontFamily="sans-serif"
android:paddingLeft="20dp"
android:paddingRight="5dp"/>
<ExpandableListView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/round_expandableListView"
android:background="#FF3C00"
android:choiceMode="multipleChoice"
android:groupIndicator="@null"
android:longClickable="true"/>
</LinearLayout>
</ScrollView>
【问题讨论】:
标签: android xml textview scrollview expandablelistview