Как я могу перекрыть Cardview в представлении изображения? - PullRequest
0 голосов
/ 24 октября 2019

My представление времени выполнения не соответствует моему представлению дизайна .

моя цель - дизайн. Design View

но когда я запускаю на андроид устройстве. Я получил этоRuntimeView Как мне перекрывать Cardview при просмотре изображений? Можно ли это сделать? сначала я использую FrameLayout, затем использую Relative Layout. Теперь я не в своем выборе. Вот мой код дизайна

<?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:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    android:background="@color/grey_10"
android:clipChildren="false"
    tools:context="com.kurtihouse.nirzonpop.detailspage.view.ProductDetailsActivity">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/app_bar_layout"
        android:layout_width="match_parent"
        android:layout_height="256dp"
        android:fitsSystemWindows="true"
        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:fitsSystemWindows="true"
            app:contentScrim="?attr/colorPrimary"
            app:expandedTitleTextAppearance="@style/TextAppearance.AppCompat.Title"
            app:layout_scrollFlags="scroll"
            app:titleEnabled="false">

            <ImageView
                android:id="@+id/ivProductImage"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:fitsSystemWindows="true"
                android:scaleType="fitXY"
                android:src="@drawable/image_8"
                app:layout_collapseMode="pin" />
            <!--<android.support.v7.widget.RecyclerView
                android:id="@+id/rvProductImage"
                android:layout_width="match_parent"
                android:layout_height="@dimen/product_image_height"
                android:layout_marginEnd="1dp"

                android:contentDescription="@string/image_description"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintHorizontal_bias="0.4"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent"
                app:srcCompat="@mipmap/ic_launcher" />-->

            <View
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="@color/overlay_dark_40" />

            <FrameLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content">

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

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

              <ImageView
                    android:layout_width="80dp"
                    android:layout_height="80dp"
                    android:tint="@android:color/white"
                    app:srcCompat="@drawable/img_wizard_1" />

               <!-- <View
                    android:layout_width="@dimen/spacing_middle"
                    android:layout_height="0dp" />

                <TextView
                    android:id="@+id/textView9"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="Nature Park"
                    android:textAppearance="@style/Base.TextAppearance.AppCompat.Title"
                    android:textColor="@android:color/white" />-->
            </LinearLayout>
        </android.support.design.widget.CollapsingToolbarLayout>
    </android.support.design.widget.AppBarLayout>
    <android.support.v4.widget.NestedScrollView
        android:id="@+id/nested_content"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginTop="-50dp"
        android:clipToPadding="false"
        android:scrollbars="vertical"
        android:scrollingCache="true"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">

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

            <android.support.v7.widget.CardView

                android:id="@+id/cardView"
                style="@style/CardViewTheme"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_anchorGravity=""
                app:layout_constraintTop_toBottomOf="@+id/rvProductImage">

                <android.support.constraint.ConstraintLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:paddingTop="10dp"
                    android:paddingBottom="10dp">

                    <ImageView
                        android:id="@+id/imageView2"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="8dp"
                        android:layout_marginEnd="8dp"
                        app:layout_constraintEnd_toEndOf="parent"
                        app:layout_constraintTop_toTopOf="parent"
                        app:srcCompat="@drawable/ic_share_gray" />


                    <ImageView
                        android:id="@+id/ivFavorite"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="8dp"
                        android:layout_marginEnd="8dp"
                        app:layout_constraintEnd_toStartOf="@+id/imageView2"
                        app:layout_constraintTop_toTopOf="parent"
                        app:srcCompat="@drawable/ic_favorite_off" />

                    <LinearLayout
                        android:id="@+id/llDirectContract"

                        android:layout_width="wrap_content"
                        android:layout_height="36dp"
                        android:layout_marginStart="16dp"
                        android:layout_marginTop="16dp"
                        android:background="@color/colorBgSuccess"
                        android:orientation="horizontal"
                        app:layout_constraintStart_toStartOf="parent"
                        app:layout_constraintTop_toBottomOf="@+id/tvProductCode">


                        <ImageView
                            android:id="@+id/ivCall111"
                            android:layout_width="@dimen/iv_call_width"
                            android:layout_height="@dimen/iv_call_height"
                            android:paddingTop="5dp"

                            app:srcCompat="@drawable/ic_phone" />

                        <TextView
                            android:id="@+id/tvDirectContractNot"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:padding="@dimen/padding_10"
                            android:text="@string/direct_buy"
                            android:textColor="@color/colorWhite"
                            android:textStyle="bold"

                            app:layout_constraintVertical_bias="0.0" />


                    </LinearLayout>

                    <TextView
                        android:id="@+id/tvPrice"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="16dp"
                        android:text=""
                        android:textColor="@color/colorBlack"
                        android:textSize="24sp"
                        android:textStyle="bold"
                        app:layout_constraintStart_toStartOf="parent"
                        app:layout_constraintTop_toTopOf="@+id/imageView2" />

                    <TextView
                        android:id="@+id/tvProductName"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="16dp"
                        android:layout_marginEnd="16dp"
                        android:text=""
                        android:textColor="@color/colorBlack"
                        android:textSize="18sp"
                        app:layout_constraintEnd_toEndOf="parent"
                        app:layout_constraintStart_toStartOf="parent"
                        app:layout_constraintTop_toBottomOf="@+id/tvPrice" />


                    <TextView
                        android:id="@+id/tvProductCode"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="16dp"
                        android:layout_marginTop="8dp"
                        android:text="swewewe"

                        app:layout_constraintStart_toStartOf="parent"
                        app:layout_constraintTop_toBottomOf="@+id/tvProductName" />

                    <TextView
                        android:id="@+id/tvAvailability"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="32dp"
                        android:background="@drawable/border_toast_success"
                        android:paddingStart="10dp"
                        android:paddingTop="3dp"
                        android:paddingEnd="10dp"
                        android:paddingBottom="3dp"
                        android:text="TextView"

                        android:textColor="@color/colorWhite"
                        android:visibility="visible"
                        app:layout_constraintBottom_toBottomOf="@+id/llDirectContract"
                        app:layout_constraintStart_toEndOf="@+id/llDirectContract"
                        app:layout_constraintTop_toTopOf="@+id/llDirectContract" />


                </android.support.constraint.ConstraintLayout>

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




            <View
                android:layout_width="match_parent"
                android:layout_height="@dimen/spacing_large" />

            <android.support.v7.widget.CardView
                android:id="@+id/sizeCardView"
                style="@style/CardViewTheme"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginBottom="8dp"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/cardView">

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

                    <TextView
                        android:id="@+id/tvSize"
                        style="@style/Text.SizeSection"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="16dp"
                        android:layout_marginTop="16dp"

                        android:text="@string/lbl_size" />


                    <TextView
                        android:id="@+id/tv_sizeList"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="16dp"
                        android:layout_marginTop="16dp"
                        android:text="dlkfjldsfjkldsjf" />
                </LinearLayout>
            </android.support.v7.widget.CardView>



            <View
                android:layout_width="match_parent"
                android:layout_height="@dimen/spacing_large" />

            <android.support.v7.widget.CardView
                android:id="@+id/detailsCardView"
                style="@style/CardViewTheme"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginBottom="8dp"
                android:paddingBottom="150dp"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/sizeCardView">

                <android.support.constraint.ConstraintLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content">

                    <TextView
                        android:id="@+id/descriptionLabel"
                        style="@style/Text.Description"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="8dp"
                        android:layout_marginTop="8dp"
                        android:text="Description"

                        app:layout_constraintStart_toStartOf="parent"
                        app:layout_constraintTop_toTopOf="parent" />

                    <TextView
                        android:id="@+id/tvDescription"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="8dp"
                        android:layout_marginTop="16dp"
                        android:layout_marginEnd="8dp"
                        android:text="deesadefdsfdasfdsaf"
                        android:textSize="13sp"
                        app:layout_constraintEnd_toEndOf="parent"
                        app:layout_constraintStart_toStartOf="parent"
                        app:layout_constraintTop_toBottomOf="@+id/descriptionLabel" />
                </android.support.constraint.ConstraintLayout>
            </android.support.v7.widget.CardView>

            <View
                android:layout_width="match_parent"
                android:layout_height="@dimen/spacing_large" />
            <Button
                android:id="@+id/btnAddCart"
                android:layout_width="@dimen/btn_add_cart_width"
                android:layout_height="40dp"
                android:layout_marginStart="8dp"
                android:layout_marginEnd="8dp"
                android:layout_marginBottom="8dp"
                android:background="@drawable/round_button"
                android:drawableStart="@drawable/ic_shopping_cart_white"
                android:paddingStart="16dp"
                android:text="@string/add_to_cart_label"
                android:textAllCaps="false"
                android:textColor="@color/colorWhite"
                android:textSize="22sp"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent" />
        </LinearLayout>
    </android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>

1 Ответ

1 голос
/ 24 октября 2019

Это происходит потому, что у вашего appbarLayout есть высота над видом карты ! Так что используйте: -

app:elevation="0dp" 

к вашему appBarLayout

...