android-图像和ExpandableListView在同一滚动视图中
作者:互联网
我有一个包含标题,图像和ExpandableListView的布局.我的问题是,虽然不必滚动标题,但我希望图像和ExpandaleListView是可以滚动的唯一块.
直到现在,除非添加高度值,否则我看不到ExpandibleListView.
这是我的布局代码:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/title"/>
</LinearLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="fill_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<LinearLayout
android:id="@+id/userContent"
android:layout_width="match_parent"
android:layout_height="175dp"
android:background="@color/black"
android:gravity="center_vertical">
<RelativeLayout
android:id="@+id/userDrawer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/transparent" >
<ImageView
android:id="@+id/ImgDrawer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:contentDescription="@string/app_name"
android:scaleType="centerCrop"
android:src="@drawable/ic_user" />
</RelativeLayout>
</LinearLayout>
<ExpandableListView
android:id="@+id/lvExp"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:focusable="false"/>
</LinearLayout>
</ScrollView>
</LinearLayout>
解决方法:
解决了将图像放入称为“页眉”的布局,然后将此代码放入活动中的问题:
final ExpandableListView elv = (ExpandableListView) v.findViewById(R.id.lvExp);
View header = inflater.inflate(R.layout.header, null);
elv.addHeaderView(header);
标签:layout,android-imageview,expandablelistview,android-scrollview,android 来源: https://codeday.me/bug/20191121/2051831.html