【发布时间】:2015-11-18 21:14:07
【问题描述】:
我有一个这样的 xml 视图,如您所见,我在其中有滚动视图,但滚动视图不滚动并且仅匹配屏幕大小,并且我无法在屏幕下看到数据。 这是我的代码: 代码已更新
<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:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/aboveRelative"
android:background="@color/darkOrange">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/category_text"
android:textSize="23sp"
android:textColor="@color/white"
android:text="Category"
android:paddingLeft="10sp" />
<GridView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/gridview"
android:layout_width="match_parent"
android:layout_height="200dp"
android:verticalSpacing="0dp"
android:horizontalSpacing="10dp"
android:numColumns="2"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/gray"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/topVoices"
android:textSize="23sp"
android:text="@string/topVoices"
android:paddingLeft="10sp" />
<ListView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/trendlist"
android:elevation="2dp"
android:background="@color/white"
android:layout_margin="10dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/moreTrend"
android:layout_gravity="right"
android:textSize="23sp"
android:text="More"
android:paddingLeft="10sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/newVoices"
android:textSize="23sp"
android:text="@string/newVoices"
android:paddingLeft="10sp" />
<ListView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/soundlist"
android:background="@color/white"
android:layout_below="@+id/newVoices"
android:elevation="5dp"
android:layout_margin="10dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/soundlist"
android:id="@+id/moreNew"
android:layout_gravity="right"
android:textSize="23sp"
android:text="@string/more"/>
<LinearLayout
android:id="@+id/yoursongs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_gravity="center"
android:background="@color/white"
android:padding="10dp">
</LinearLayout>
</LinearLayout>
</LinearLayout>
我确定屏幕下有一些数据,但滚动视图不允许我滚动它并看到它们。
【问题讨论】:
-
所以,它应该只有一个孩子,但查看你的代码,我认为你确实有它。另外,由于您使用的是RelativeLayout,您能否看到它是否以某种方式结束在循环中重新测量您的显示,因为它是滚动视图?而相对布局适应最大?我会尝试将所有RelativeLayouts 更改为LinearLayout,只是为了看看是否是这种情况。另外,你为什么不删除根处的 LinearLayout 并将 ScrollView 保留为根?
-
我照你说的做了,但结果并没有什么不同。
-
您在 ScrollView 中有一个 ListView,这可能不起作用?检查此链接:developer.android.com/intl/es/reference/android/widget/… 明确表示您不应在滚动视图中使用列表视图。
标签: android xml scrollview