如何将水平回收视图放在垂直scrollview

时间:2015-05-30 03:43:52

标签: android android-layout

我试图在垂直滚动视图中放置六个水平回收视图行。我所拥有的是一系列顶级回收按钮,让我选择一个日期,然后是六个水平回收者视图,让我选择项目,然后是底行三个按钮

没有滚动视图的片段代码如下:

<FrameLayout 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"
    tools:context="db.cbm.com.myapp.MenuPickerFragment">

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_gravity="center"
        android:orientation="vertical">

        <TextView
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="0.25"
            android:text="@string/pick_menu" />

        <LinearLayout
            android:id="@+id/datePickerView"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_gravity="center_horizontal"
            android:layout_weight="1"
            android:orientation="horizontal">

            <android.support.v7.widget.RecyclerView
                android:id="@+id/day_of_week_list"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"></android.support.v7.widget.RecyclerView>
        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="6"
            android:orientation="vertical">

            <LinearLayout
                android:id="@+id/breakfastScrollView"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:orientation="horizontal">

                <android.support.v7.widget.RecyclerView
                    android:id="@+id/breakfastList"
                    android:layout_width="wrap_content"
                    android:layout_height="match_parent"></android.support.v7.widget.RecyclerView>
            </LinearLayout>

            <LinearLayout
                android:id="@+id/snack1ScrollView"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:orientation="horizontal">

                <android.support.v7.widget.RecyclerView
                    android:id="@+id/snack1List"
                    android:layout_width="wrap_content"
                    android:layout_height="match_parent"></android.support.v7.widget.RecyclerView>
            </LinearLayout>

            <LinearLayout
                android:id="@+id/lunchScrollView"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:orientation="horizontal">

                <android.support.v7.widget.RecyclerView
                    android:id="@+id/lunchList"
                    android:layout_width="wrap_content"
                    android:layout_height="match_parent"></android.support.v7.widget.RecyclerView>
            </LinearLayout>

            <LinearLayout
                android:id="@+id/snack2ScrollView"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:orientation="horizontal">

                <android.support.v7.widget.RecyclerView
                    android:id="@+id/snack2List"
                    android:layout_width="wrap_content"
                    android:layout_height="match_parent"></android.support.v7.widget.RecyclerView>
            </LinearLayout>

            <LinearLayout
                android:id="@+id/dinnerLayout"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:orientation="horizontal">

                <android.support.v7.widget.RecyclerView
                    android:id="@+id/dinnerList"
                    android:layout_width="wrap_content"
                    android:layout_height="match_parent"></android.support.v7.widget.RecyclerView>
            </LinearLayout>

            <LinearLayout
                android:id="@+id/snack3ScrollView"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:orientation="horizontal">

                <android.support.v7.widget.RecyclerView
                    android:id="@+id/snack3List"
                    android:layout_width="wrap_content"
                    android:layout_height="match_parent"></android.support.v7.widget.RecyclerView>
            </LinearLayout>
        </LinearLayout>

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

            <Button
                android:id="@+id/button4"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:text="@string/cancel" />

            <Button
                android:id="@+id/button5"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:text="@string/save" />

            <Button
                android:id="@+id/button6"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:text="@string/done" />
        </LinearLayout>
    </LinearLayout>
</FrameLayout>

The above works correctly except the images in the six menu picker recycler view rows are too small so I would like to increase their size and put them into a vertical scroll view.

Here's what I think I want but it doesn't work, none of my recyclerviews are present or at least they're not initialized and I don't see any rows. Any idea what I'm doing wrong?

<FrameLayout 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"
    tools:context="db.cbm.com.myApp.MenuPickerFragment">

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_gravity="center"
        android:orientation="vertical">

        <TextView
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="0.25"
            android:text="@string/pick_menu" />

        <LinearLayout
            android:id="@+id/datePickerView"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_gravity="center_horizontal"
            android:layout_weight="1"
            android:orientation="horizontal">

            <android.support.v7.widget.RecyclerView
                android:id="@+id/day_of_week_list"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"></android.support.v7.widget.RecyclerView>
        </LinearLayout>

        <ScrollView
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="6">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"

                android:orientation="vertical">

                <LinearLayout
                    android:id="@+id/breakfastScrollView"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="horizontal">

                    <android.support.v7.widget.RecyclerView
                        android:id="@+id/breakfastList"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"></android.support.v7.widget.RecyclerView>
                </LinearLayout>

                <LinearLayout
                    android:id="@+id/snack1ScrollView"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="horizontal">

                    <android.support.v7.widget.RecyclerView
                        android:id="@+id/snack1List"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"></android.support.v7.widget.RecyclerView>
                </LinearLayout>

                <LinearLayout
                    android:id="@+id/lunchScrollView"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="horizontal">

                    <android.support.v7.widget.RecyclerView
                        android:id="@+id/lunchList"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"></android.support.v7.widget.RecyclerView>
                </LinearLayout>

                <LinearLayout
                    android:id="@+id/snack2ScrollView"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="horizontal">

                    <android.support.v7.widget.RecyclerView
                        android:id="@+id/snack2List"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"></android.support.v7.widget.RecyclerView>
                </LinearLayout>

                <LinearLayout
                    android:id="@+id/dinnerLayout"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="horizontal">

                    <android.support.v7.widget.RecyclerView
                        android:id="@+id/dinnerList"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"></android.support.v7.widget.RecyclerView>
                </LinearLayout>

                <LinearLayout
                    android:id="@+id/snack3ScrollView"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="horizontal">

                    <android.support.v7.widget.RecyclerView
                        android:id="@+id/snack3List"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"></android.support.v7.widget.RecyclerView>
                </LinearLayout>
            </LinearLayout>
        </ScrollView>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:orientation="horizontal">
            <Button
                android:id="@+id/button4"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:text="@string/cancel" />

            <Button
                android:id="@+id/button5"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:text="@string/save" />

            <Button
                android:id="@+id/button6"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:text="@string/done" />
        </LinearLayout>
    </LinearLayout>
</FrameLayout>

非常感谢任何帮助,谢谢!

0 个答案:

没有答案