首先,对于我的英语不好,对于如何显示我的“可扩展列表视图”和“网格视图”,我感到很抱歉,在尝试这样做时,我遇到了错误
:渲染期间引发异常:
Scroll View can host only one direct child
Exception details are logged in Window > Show View > Error Log
代码 :
<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"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.samp.sampleproh.MainActivity"
android:orientation="vertical" >
<ExpandableListView
android:id="@+id/lvExp"
android:layout_width="match_parent"
android:layout_height="205dp"
android:layout_weight="0.41"
android:cacheColorHint="#00000000" >
</ExpandableListView>
<GridView
android:id="@+id/gridview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:columnWidth="90dp"
android:numColumns="auto_fit"
android:verticalSpacing="10dp"
android:horizontalSpacing="10dp"
android:stretchMode="columnWidth"
android:gravity="center"/>
</ScrollView>
您需要将可扩展的listview和gridview添加到一种常见的相对布局中,这将解决您的问题。
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ExpandableListView
android:id="@+id/lvExp"
android:layout_width="match_parent"
android:layout_height="205dp"
android:layout_weight="0.41"
android:cacheColorHint="#00000000"></ExpandableListView>
<GridView
android:id="@+id/gridview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="@+id/lvExp"
android:columnWidth="90dp"
android:gravity="center"
android:horizontalSpacing="10dp"
android:numColumns="auto_fit"
android:stretchMode="columnWidth"
android:verticalSpacing="10dp" />
</RelativeLayout>
</ScrollView>
</RelativeLayout>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句