【发布时间】:2023-03-25 04:23:01
【问题描述】:
我正在尝试实现这种布局
<RelativeLayout>
<LinearLayout> <!-- Always attached to the top of the parent -->
<RecyclerView>
<LinearLayout> <!-- Always attached to the bottom of the parent -->
<GridView>
<RelativeLayout>
这是在相对布局中的两个线性布局之间具有回收器视图的完整代码
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff">
<LinearLayout
android:id="@+id/LinearLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.v4.view.ViewPager
android:id="@+id/view_pager"
android:layout_width="match_parent"
android:layout_height="160dp"/>
<LinearLayout
android:id="@+id/layoutDots"
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_alignBottom="@id/view_pager"
android:layout_centerVertical="true"
android:gravity="center"
android:orientation="horizontal" />
<View android:id="@+id/view1"
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:layout_below="@id/view_pager"
android:background="@android:color/darker_gray" />
</LinearLayout>
<LinearLayout
android:id="@+id/LinearLayout1"
android:layout_below="@id/LinearLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<View android:layout_width="0dp"
android:layout_height="1dp"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:layout_margin="10dp"
android:background="@android:color/darker_gray" />
<TextView
android:id="@+id/orLoginWithEmail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:gravity="center_vertical"
android:text="Shop By Category"
android:textColor="@color/black"
android:textSize="16sp" />
<View
android:layout_width="0dp"
android:layout_height="1dp"
android:layout_weight="1"
android:layout_gravity="center_vertical"
android:layout_margin="10dp"
android:background="@android:color/darker_gray" />
</LinearLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/listView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@id/LinearLayout1"
android:layout_below="@id/LinearLayout"
android:background="@android:color/white"
android:orientation="horizontal"/>
<GridView
android:id="@+id/gridview"
android:layout_below="@id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:horizontalSpacing="10dp"
android:numColumns="4"
android:paddingLeft="2dp"
android:paddingRight="2dp"
android:paddingTop="10dp"
android:verticalSpacing="20dp"></GridView>
</RelativeLayout>
我试图在父相对布局内的两个线性布局之间放置回收器视图,但它没有显示回收器视图。我认为它与某些视图重叠或可能是任何其他问题。我当前的布局输出是
【问题讨论】:
-
你想要 Linear -> recylerView -> LinearLayout 从上到下的顺序对吗?
-
您是否需要 Recyclerview 和 GridView 自己在里面滚动,或者您想滚动 recyclerview 的所有项目然后显示“按类别购物”然后启动 GridView?
标签: android android-layout listview