0
我想设置一个RecyclerView和一个GridView分别占用布局的70%和30%。 我为此也使用了一个片段。RecyclerView和GridView中的一个片段XML
与该XML,既不观点出现在屏幕上:
<RelativeLayout 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:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
android:elevation="5dp"
tools:context="shamak.self.eventplanner.activities.Activity_NewEvent$PlaceholderFragment">
<TextView
android:id="@+id/section_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="1">
<android.support.v7.widget.RecyclerView
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.7"
tools:context=".Fragment_i"
/>
<GridView
android:id="@+id/grid_view"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.3"
android:numColumns="2"
android:verticalSpacing="5dp"
android:horizontalSpacing="5dp"
>
</GridView>
</LinearLayout>
</RelativeLayout>
设置为match_parent
代替RecyclerView的layout_height
,该RecyclerView填充整个屏幕:
<android.support.v7.widget.RecyclerView
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Fragment_i"
/>