7

我正在尝试创建 Android 产品布局。在页脚有两个按钮,它是固定按钮。当我向上滚动布局中附加的底部两个按钮时,您可以看到图像。请帮助我该怎么办?

图 1

在此处输入图像描述

图 2

滚动后

在此处输入图像描述

xml

<?xml version="1.0" encoding="utf-8"?>
<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:id="@+id/coordinate"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:context="com.chivazo.chivazoandroid.activities.SingleProductActivity">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/app_bar"
        android:layout_width="match_parent"
        android:layout_height="@dimen/app_bar_height"
        android:fitsSystemWindows="true"
        android:theme="@style/AppTheme.AppBarOverlay">

        <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/toolbar_layout"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fitsSystemWindows="true"
            app:contentScrim="?attr/colorPrimary"
            app:expandedTitleMarginBottom="30dp"
            app:expandedTitleMarginEnd="64dp"
            app:expandedTitleMarginStart="48dp"
            app:layout_scrollFlags="scroll|exitUntilCollapsed">

            <ImageView
                android:id="@+id/backdrop"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:fitsSystemWindows="true"
                android:scaleType="centerCrop"
                android:src="@drawable/a"
                app:layout_collapseMode="parallax" />

            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                app:layout_collapseMode="pin"
                app:popupTheme="@style/AppTheme.PopupOverlay" />

        </android.support.design.widget.CollapsingToolbarLayout>
    </android.support.design.widget.AppBarLayout>

    <include layout="@layout/content_single_product" />


    <LinearLayout
        android:id="@+id/groupbutton"
        android:weightSum="2"
        android:orientation="horizontal"
        android:layout_gravity="bottom"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        >
        <android.support.v7.widget.AppCompatButton
            android:layout_weight="1"
            android:id="@+id/share"
            android:text="share"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
        <android.support.v7.widget.AppCompatButton
            android:layout_weight="1"
            android:id="@+id/go_wishlist"
            android:text="go to Wishlist"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
    </LinearLayout>


</android.support.design.widget.CoordinatorLayout>
4

5 回答 5

14

您可以将Relativelayout其用作外部布局并保留CoordinatorLayout在其中,制作两个按钮android:layout_alignParentBottom="true"

 <?xml version="1.0" encoding="utf-8"?>

<RelativeLayout 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"
    android:orientation="vertical">

    <android.support.design.widget.CoordinatorLayout
        android:id="@+id/coordinate"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/groupbutton"
        android:fitsSystemWindows="true"
        tools:context="com.chivazo.chivazoandroid.activities.SingleProductActivity">

        <android.support.design.widget.AppBarLayout
            android:id="@+id/app_bar"
            android:layout_width="match_parent"
            android:layout_height="@dimen/app_bar_height"
            android:fitsSystemWindows="true"
            android:theme="@style/AppTheme.AppBarOverlay">

            <android.support.design.widget.CollapsingToolbarLayout
                android:id="@+id/toolbar_layout"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:fitsSystemWindows="true"
                app:contentScrim="?attr/colorPrimary"
                app:expandedTitleMarginBottom="30dp"
                app:expandedTitleMarginEnd="64dp"
                app:expandedTitleMarginStart="48dp"
                app:layout_scrollFlags="scroll|exitUntilCollapsed">

                <ImageView
                    android:id="@+id/backdrop"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:fitsSystemWindows="true"
                    android:scaleType="centerCrop"
                    android:src="@drawable/a"
                    app:layout_collapseMode="parallax" />

                <android.support.v7.widget.Toolbar
                    android:id="@+id/toolbar"
                    android:layout_width="match_parent"
                    android:layout_height="?attr/actionBarSize"
                    app:layout_collapseMode="pin"
                    app:popupTheme="@style/AppTheme.PopupOverlay" />

            </android.support.design.widget.CollapsingToolbarLayout>
        </android.support.design.widget.AppBarLayout>

        <include layout="@layout/content_single_product" />
    </android.support.design.widget.CoordinatorLayout>

    <LinearLayout
        android:id="@+id/groupbutton"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_gravity="bottom"
        android:orientation="horizontal"
        android:weightSum="2">

        <android.support.v7.widget.AppCompatButton
            android:id="@+id/share"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="share" />

        <android.support.v7.widget.AppCompatButton
            android:id="@+id/go_wishlist"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="go to Wishlist" />
    </LinearLayout>
</RelativeLayout>
于 2016-05-09T10:47:14.963 回答
2

app:layout_anchor="@id/anchor_view" 和 是这里的 app:layout_anchorGravity="bottom"
重要属性

 <android.support.design.widget.CoordinatorLayout
            android:id="@+id/coordinator_layout"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fitsSystemWindows="true"
            tools:context=".ProductDetailActivity">

     <android.support.design.widget.AppBarLayout
            android:id="@+id/app_bar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

    <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/collapsing_toolbar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:layout_scrollFlags="scroll">

     <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="@color/colorPrimary"/>

     </android.support.design.widget.CollapsingToolbarLayout>
     </android.support.design.widget.AppBarLayout>

     <android.support.v4.widget.NestedScrollView
                android:id="@+id/nested_scroll"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                app:layout_behavior="@string/appbar_scrolling_view_behavior">
                .
                .
                .

                <View
                android:id="@+id/anchor_view"
                android:layout_width="match_parent"
                android:layout_height="wrap_content" />
                .
                .
                .
                .
      </android.support.v4.widget.NestedScrollView>

     <LinearLayout

                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal"
                app:layout_anchor="@id/anchor_view"
                app:layout_anchorGravity="bottom">

                <Button
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"/>


                <Button
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"/>
            </LinearLayout>
     </android.support.design.widget.CoordinatorLayout>
于 2017-08-04T11:58:20.313 回答
1

只需在 xml 中的 NestedScrollView 下方的 Coordinatorlayout 中添加您的布局,然后在 java 中执行以下操作。

CoordinatorLayout.LayoutParams layoutParams = (CoordinatorLayout.LayoutParams) layoutToBeAnchored.getLayoutParams();
    layoutParams.setAnchorId(R.id.layoutBelowWhichToBeAnchored);
    layoutParams.anchorGravity = Gravity.CENTER;
    layoutToBeAnchored.setLayoutParams(layoutParams);

希望这对你们有帮助。对于任何参考,您可以查看示例 - https://github.com/IsUncommon/Droidcon-India-2015

于 2016-09-30T10:51:23.377 回答
0

如果您包含的布局layout="@layout/content_single_product"包含一个NestedScrollView作为根视图容器。尝试向它添加一个 id ,您可能必须添加与按钮高度值相同的底部填充@+id/nestedView, 然后保持其余部分不变,并在包含两个按钮的底部线性布局中替换为:android:layout_height="match_parent"android:layout_gravity="bottom"

app:layout_anchor="@id/nestedView" app:layout_anchorGravity="bottom"

于 2017-05-05T22:03:34.203 回答
0
<RelativeLayout 
 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.support.design.widget.CoordinatorLayout
        android:id="@+id/coordinatorLayout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fitsSystemWindows="true"
        android:orientation="vertical">



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

            <android.support.design.widget.CollapsingToolbarLayout
                android:id="@+id/collapsing_toolbar"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="@android:color/transparent"
                app:contentScrim="?attr/colorPrimary"
                app:expandedTitleGravity="center_vertical|start"
                app:expandedTitleTextAppearance="@android:color/transparent"
                app:layout_collapseMode="parallax"
                app:layout_scrollFlags="scroll|exitUntilCollapsed">

                <RelativeLayout
                    android:id="@+id/lay_image_slider"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_below="@+id/browseCategories"
                    android:background="@color/white">

                    <FrameLayout
                        android:id="@+id/rel"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:background="@android:color/white"
                        android:orientation="vertical">

                        <com.example.android_dev.ecm.View.ViewPagerCustomDuration
                            android:id="@+id/pager"
                            android:layout_width="fill_parent"
                            android:layout_height="300dp" />

                        <com.example.android_dev.ecm.View.CirclePageIndicator
                            android:id="@+id/indicator"
                            android:layout_width="fill_parent"
                            android:layout_height="wrap_content"
                            android:layout_gravity="bottom"
                            android:background="@android:color/transparent"
                            android:padding="10dp" />
                    </FrameLayout>
                </RelativeLayout>

                <android.support.v7.widget.Toolbar
                    android:id="@+id/toolbarSeller"
                    android:layout_width="match_parent"
                    android:layout_height="?attr/actionBarSize"
                    android:minHeight="56dp"
                    app:layout_collapseMode="pin" />


            </android.support.design.widget.CollapsingToolbarLayout>
        </android.support.design.widget.AppBarLayout>

        <include
            android:id="@+id/contentScroll"
            layout="@layout/content_scroll_product_detail" />
    </android.support.design.widget.CoordinatorLayout>


    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_gravity="bottom"
        android:orientation="vertical">

        <View
            android:layout_width="match_parent"
            android:layout_height="8dp"
            android:layout_gravity="center"
            android:background="@drawable/shadow" />

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:weightSum="2">

            <Button
                android:id="@+id/addToCart"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:background="@color/white"
                android:text="Add To Cart"
                android:textColor="@color/black"
                android:textSize="16sp" />

            <!--<Button
                android:id="@+id/addToWishList"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:background="@color/colorAccent"
                android:text="Add To Wishlist"
                android:textColor="@color/white" />-->

            <Button
                android:id="@+id/buyNow1"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:background="@color/colorPrimary"
                android:text="Buy Now"
                android:textColor="@color/white"
                android:textSize="16sp" />

        </LinearLayout>

    </LinearLayout>
</RelativeLayout>

content_scroll_product_detail.xml:

 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:expandableTextView="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_behavior="com.example.android_dev.ecm.Helper.FixedScrollingViewBehaviour">

        <android.support.v4.widget.NestedScrollView
            android:id="@+id/nestedScroll"
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical">

                <android.support.v7.widget.CardView
                    android:id="@+id/productDetails"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="5dp">

                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:orientation="vertical">

                        <TextView
                            android:id="@+id/productTitle"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:paddingLeft="10dp"
                            android:paddingRight="10dp"
                            android:paddingTop="10dp"
                            android:textColor="@color/black"
                            android:textSize="18sp" />

                        <TextView
                            android:id="@+id/productName"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:paddingLeft="10dp"
                            android:paddingRight="10dp"
                            android:paddingTop="2dp"
                            android:textSize="16sp" />

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

                            <TextView
                                android:id="@+id/productDiscountPrice"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_marginLeft="10dp"
                                android:gravity="center"
                                android:paddingLeft="10dp"
                                android:paddingRight="10dp"
                                android:paddingTop="10dp"
                                android:textColor="@color/black"
                                android:textSize="18sp"
                                android:textStyle="bold" />

                            <TextView
                                android:id="@+id/productPrice"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_marginLeft="10dp"
                                android:layout_toRightOf="@+id/productDiscountPrice"
                                android:gravity="center"
                                android:paddingLeft="10dp"
                                android:paddingRight="10dp"
                                android:paddingTop="10dp"
                                android:textColor="@color/gray"
                                android:textSize="14sp" />

                            <LinearLayout
                                android:id="@+id/ratingProduct"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_alignParentRight="true"
                                android:layout_marginRight="10dp"
                                android:orientation="horizontal">

                                <TextView
                                    android:id="@+id/rating"
                                    android:layout_width="wrap_content"
                                    android:layout_height="wrap_content"
                                    android:layout_marginTop="5dp"
                                    android:padding="10dp"
                                    android:text="3.2"
                                    android:textColor="@color/colorAccent"
                                    android:textSize="22sp" />

                                <RatingBar
                                    android:id="@+id/star"
                                    android:layout_width="wrap_content"
                                    android:layout_height="wrap_content"
                                    android:layout_toRightOf="@+id/rating"
                                    android:isIndicator="true"
                                    android:numStars="1"
                                    android:rating="1" />
                            </LinearLayout>

                            <LinearLayout
                                android:id="@+id/sold"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_below="@+id/productPrice"
                                android:layout_marginLeft="10dp"
                                android:layout_marginTop="10dp"
                                android:orientation="horizontal">

                                <TextView
                                    android:layout_width="wrap_content"
                                    android:layout_height="wrap_content"
                                    android:text="Sold by : "
                                    android:textColor="@color/gray"
                                    android:textSize="14sp" />

                                <TextView
                                    android:id="@+id/soldBy"
                                    android:layout_width="wrap_content"
                                    android:layout_height="wrap_content"
                                    android:textColor="@color/gray"
                                    android:textSize="14sp" />
                            </LinearLayout>

                            <TextView
                                android:id="@+id/orders"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_below="@+id/sold"
                                android:layout_marginLeft="10dp"
                                android:layout_marginTop="10dp"
                                android:textSize="20sp"
                                android:textStyle="bold" />

                        </RelativeLayout>

                        <TextView
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:paddingLeft="10dp"
                            android:paddingRight="10dp"
                            android:paddingTop="10dp"
                            android:text="Additional tax may apply charged at checkout"
                            android:textSize="14sp" />

                        <LinearLayout
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:orientation="horizontal"
                            android:paddingTop="10dp"
                            android:weightSum="1">

                            <Button
                                android:id="@+id/share"
                                android:layout_width="0dp"
                                android:layout_height="wrap_content"
                                android:layout_gravity="center"
                                android:layout_weight="0.5"
                                android:background="@drawable/lay_border"
                                android:drawableLeft="@drawable/shareic"
                                android:drawablePadding="-20dp"
                                android:gravity="center"
                                android:paddingLeft="8dp"
                                android:text="Share"
                                android:textColor="@color/black" />

                            <Button
                                android:id="@+id/addToWishList"
                                android:layout_width="0dp"
                                android:layout_height="wrap_content"
                                android:layout_gravity="center"
                                android:layout_weight="0.5"
                                android:background="@drawable/lay_border"
                                android:drawableLeft="@drawable/pinic"
                                android:drawablePadding="-10dp"
                                android:gravity="center"
                                android:paddingLeft="8dp"
                                android:text="Add To Pinlist"
                                android:textColor="@color/black" />

                        </LinearLayout>

                    </LinearLayout>
                </android.support.v7.widget.CardView>


                <android.support.v7.widget.CardView
                    android:id="@+id/ratingSeller"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_below="@+id/productDetails">

                    <RelativeLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:padding="2dp">

                    </RelativeLayout>
                </android.support.v7.widget.CardView>

                <TextView
                    android:id="@+id/outOfStock"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_below="@+id/ratingSeller"
                    android:background="@color/light_red"
                    android:gravity="center"
                    android:text="Sorry this product is out of stock."
                    android:textColor="@color/white"
                    android:textSize="22sp"
                    android:visibility="gone" />

                <android.support.v7.widget.CardView
                    android:id="@+id/productVariants"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_below="@+id/outOfStock"
                    android:layout_marginTop="5dp">

                    <LinearLayout
                        android:id="@+id/addAttributesHere"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:orientation="vertical">

                    </LinearLayout>
                </android.support.v7.widget.CardView>

                <LinearLayout
                    android:id="@+id/saveButtons"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_below="@id/productVariants"
                    android:orientation="horizontal"
                    android:visibility="gone"
                    android:weightSum="2">

                    <Button
                        android:id="@+id/add"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:background="@color/black"
                        android:text="Add To Cart"
                        android:textColor="@color/white" />

                    <!--       <Button
                               android:id="@+id/save"
                               android:layout_width="match_parent"
                               android:layout_height="wrap_content"
                               android:layout_weight="1"
                               android:background="@color/colorAccent"
                               android:text="Add To Wishlist"
                               android:textColor="@color/white" />-->

                    <Button
                        android:id="@+id/buyNow2"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:background="@color/colorAccent"
                        android:text="Buy Now"
                        android:textColor="@color/white" />

                </LinearLayout>


                <android.support.v7.widget.CardView
                    android:id="@+id/description"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_below="@+id/saveButtons"
                    android:layout_marginTop="2dp">

                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:orientation="vertical">

                        <TextView
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:paddingLeft="10dp"
                            android:paddingRight="10dp"
                            android:text="Description"
                            android:textColor="@color/black"
                            android:textSize="16sp"
                            android:textStyle="bold" />

                        <com.ms.square.android.expandabletextview.ExpandableTextView
                            android:id="@+id/expand_text_view"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            expandableTextView:animDuration="200"
                            expandableTextView:maxCollapsedLines="2">

                            <TextView
                                android:id="@+id/expandable_text"
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:paddingLeft="10dp"
                                android:paddingRight="10dp"
                                android:paddingTop="10dp"
                                android:textColor="@color/black"
                                android:textSize="14sp" />

                            <ImageButton
                                android:id="@id/expand_collapse"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_gravity="right|bottom"
                                android:background="@android:color/transparent"
                                android:padding="16dp" />
                        </com.ms.square.android.expandabletextview.ExpandableTextView>
                    </LinearLayout>
                </android.support.v7.widget.CardView>

                <android.support.v7.widget.CardView
                    android:id="@+id/recommend"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_below="@+id/description"
                    android:layout_marginTop="5dp">

                    <RelativeLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:background="@color/white">

                        <TextView
                            android:id="@+id/recommendHead"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:padding="10dp"
                            android:text="Recommendation"
                            android:textColor="@color/black"
                            android:textSize="16sp"
                            android:textStyle="bold" />

                        <TextView
                            android:id="@+id/recommendText"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_below="@+id/recommendHead"
                            android:padding="10dp"
                            android:text="Would you like to recommend this product?"
                            android:textColor="@color/gray"
                            android:textSize="14sp" />

                        <LinearLayout
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_below="@+id/recommendText"
                            android:layout_marginBottom="5dp"
                            android:background="@drawable/lay_border"
                            android:weightSum="2">

                            <Button
                                android:id="@+id/yes"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_gravity="right"
                                android:layout_weight="1"
                                android:background="#deffffff"
                                android:text="Yes"
                                android:textColor="@color/colorPrimary"
                                android:textSize="18sp" />

                            <Button
                                android:id="@+id/no"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_gravity="left"
                                android:layout_weight="1"
                                android:background="#f7f5f5"
                                android:text="No"
                                android:textColor="@color/colorPrimary"
                                android:textSize="18sp" />
                        </LinearLayout>

                    </RelativeLayout>
                </android.support.v7.widget.CardView>

                <android.support.v7.widget.CardView
                    android:id="@+id/productSellers"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_below="@+id/recommend"
                    android:layout_marginTop="5dp">

                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:orientation="vertical">

                        <android.support.v7.widget.RecyclerView
                            android:id="@+id/addSellersHere"
                            android:layout_width="match_parent"
                            android:layout_height="0dp"
                            android:layout_weight="1">

                        </android.support.v7.widget.RecyclerView>
                    </LinearLayout>
                </android.support.v7.widget.CardView>
            </LinearLayout>


        </android.support.v4.widget.NestedScrollView>


    </RelativeLayout>
于 2018-02-23T06:07:16.663 回答