如何滚动包含视图和recyclerView的视图寻呼机

时间:2017-11-02 09:38:04

标签: android android-layout scroll android-recyclerview android-viewpager

我有一个包含两个孩子的视图寻呼机
1 - 查看一些数据
2 - 查看寻呼机(包含RecyclerView)。

我的问题是RecyclerView看起来不太好只是两个cardView出现了(如果设备高度小于我的回收器不会出现)。
我想让父视图分页器可以滚动来解决这个问题。

这是我的设计

enter image description here


我的xml代码:
1)父视图寻呼机

<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Menus.MenusActivity">

<android.support.design.widget.AppBarLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="?attr/colorPrimary"
        app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
        app:theme="@style/ThemeOverlay.AppCompat.Light" />

    <View
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:background="@color/textColorPrimary" />

    <android.support.design.widget.TabLayout
        android:id="@+id/tabs"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:tabGravity="fill"
        app:tabIndicatorColor="@color/textColorPrimary"
        app:tabMode="fixed"
        app:tabSelectedTextColor="@color/colorPrimaryDark"
        app:tabTextColor="@color/textColorPrimary" />
</android.support.design.widget.AppBarLayout>


<seif.example.com.jahhizly.Other.NonSwipeableViewPager
    android:id="@+id/viewpager"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:nestedScrollingEnabled="true"
    app:layout_behavior="@string/appbar_scrolling_view_behavior" />

2)包含第二个视图寻呼机的片段

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:orientation="vertical">

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@color/white"
    android:orientation="horizontal"
    android:paddingBottom="8dp"
    android:paddingLeft="16dp"
    android:paddingRight="16dp"
    android:paddingTop="8dp">

    <ImageView
        android:id="@+id/menu_branch_logo"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:scaleType="fitXY"
        android:src="@mipmap/con_burgerking" />

    <LinearLayout
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_marginLeft="8dp"
        android:layout_weight="2.5"
        android:orientation="vertical">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1.5">

            <TextView
                android:id="@+id/menu_branch_name"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginRight="8dp"
                android:text="BURGER King"
                android:textSize="20dp" />

            <ImageView
                android:id="@+id/menu_branch_status"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                android:layout_toRightOf="@id/menu_branch_name"
                android:src="@mipmap/con_open_restaurant" />
        </RelativeLayout>

        <TextView
            android:id="@+id/menu_branch_category"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:text="Type of food" />

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="3"
            android:orientation="horizontal">

            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="0.8"></LinearLayout>

            <Button
                android:id="@+id/menu_book_table_btn"
                android:layout_width="0dp"
                android:layout_height="45dp"
                android:layout_weight="1.2"
                android:background="@mipmap/login_background"
                android:text="Book Table"
                android:textColor="@color/white" />
        </LinearLayout>
    </LinearLayout>

</LinearLayout>

<View
    android:layout_width="match_parent"
    android:layout_height="1dp"
    android:background="@color/sideMenuTxtColor" />

<android.support.design.widget.TabLayout
    android:id="@+id/tabs_details"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@color/colorPrimary"
    app:tabGravity="fill"
    app:tabIndicatorColor="@color/textColorPrimary"
    app:tabMode="scrollable"
    app:tabSelectedTextColor="@color/colorPrimaryDark"
    app:tabTextColor="@color/textColorPrimary" />

<android.support.v4.view.ViewPager
    android:id="@+id/viewpager_details"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior" />

3)仅包含RecyclerView的子视图寻呼机... 我两天前就陷入了这个问题..任何人都可以帮我一把?

0 个答案:

没有答案