约束布局-如何使图像视图(框架)在整个屏幕上移动

时间:2019-05-27 12:18:49

标签: android android-constraintlayout

我有一个像火种一样的卡片视图约束布局。我已经更改了该视图的大小,并且可以移动(喜欢/不喜欢)。但是图像被剪切了(因为它在内部框架中)。我想在整个屏幕上手动移动框架。

这是布局文件

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
        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/root_content_list"
        android:background="@color/white"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

    <in.zapr.onemedia.custom.ZTextView
            android:id="@+id/heading"
            android:layout_width="wrap_content"
            android:layout_height="0dp"
            app:layout_constraintHeight_percent="0.1"
            android:text="@string/card_title"
            app:layout_constraintLeft_toLeftOf="parent"
            app:layout_constraintRight_toRightOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            android:layout_marginLeft="16dp"
            android:layout_marginRight="16dp"
            android:layout_gravity="center"
            android:gravity="bottom"
            android:textColor="@color/cs_title"
            app:type_face="@string/font_heavy"
            android:textAppearance="?android:textAppearanceLarge"/>

    <in.zapr.onemedia.custom.ZTextView
            android:id="@+id/headingTip"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dp"
            android:text="@string/card_tip"
            android:layout_gravity="center"
            android:gravity="center"
            android:textColor="@color/cs_subtitle"
            app:type_face="@string/font_heavy"
            app:layout_constraintLeft_toLeftOf="@id/heading"
            app:layout_constraintRight_toRightOf="@id/heading"
            app:layout_constraintTop_toBottomOf="@id/heading"
            android:textAppearance="?android:textAppearanceSmall"/>
    <ProgressBar
            android:id="@+id/pb_loading_content_selection"
            android:layout_width="50dp"
            android:layout_height="0dp"
            app:layout_constraintLeft_toLeftOf="@id/ll_cardView"
            app:layout_constraintRight_toRightOf="@id/ll_cardView"
            app:layout_constraintTop_toTopOf="@id/ll_cardView"
            app:layout_constraintBottom_toBottomOf="@id/ll_cardView"
            android:layout_marginLeft="8dp"
            android:layout_marginStart="8dp"
            android:layout_marginEnd="8dp"
            android:layout_gravity="center"
            android:layout_marginRight="8dp"
            android:layout_marginTop="8dp"
            android:visibility="gone"/>

    <ImageView
            android:id="@+id/btn_retry_content_selection"
            android:layout_width="50dp"
            android:layout_height="0dp"
            app:layout_constraintLeft_toLeftOf="@id/ll_cardView"
            app:layout_constraintRight_toRightOf="@id/ll_cardView"
            app:layout_constraintTop_toTopOf="@id/ll_cardView"
            app:layout_constraintBottom_toBottomOf="@id/ll_cardView"
            android:padding="10dp"
            android:visibility="gone"
            android:layout_gravity="center"
            app:srcCompat="@drawable/reload"/>


    <LinearLayout
            android:id="@+id/ll_cardView"
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:orientation="vertical"
            app:layout_constraintHeight_percent="0.45"
            app:layout_constraintWidth_percent="0.6"
            android:layout_marginTop="10dp"
            app:layout_constraintTop_toBottomOf="@id/headingTip"
            app:layout_constraintBottom_toTopOf="@id/button_container"
            app:layout_constraintLeft_toLeftOf="parent"
            app:layout_constraintRight_toRightOf="parent">

        <ImageView
                android:id="@+id/cardViewBackground"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:visibility="gone"
                app:srcCompat="@drawable/no_content_available"
                android:clipToPadding="false"/>

        <com.yuyakaido.android.cardstackview.CardStackView
                android:id="@+id/card_stack_view"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:visibility="visible"
                android:clipToPadding="false">
        </com.yuyakaido.android.cardstackview.CardStackView>

    </LinearLayout>


    <RelativeLayout
            android:id="@+id/button_container"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            app:layout_constraintHeight_percent="0.25"
            app:layout_constraintBottom_toTopOf="@id/ll_Next"
            app:layout_constraintTop_toBottomOf="@id/ll_cardView"
            android:clipChildren="false">

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

            <android.support.design.widget.FloatingActionButton
                    android:id="@+id/skip_button"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:scaleType="fitXY"
                    app:fabSize="normal"
                    app:borderWidth="0dp"
                    android:padding="0dp"
                    app:useCompatPadding="true"
                    app:srcCompat="@drawable/onboarding_dislike"
                    app:backgroundTint="@android:color/white"/>

            <android.support.design.widget.FloatingActionButton
                    android:id="@+id/maybe_button"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:scaleType="fitXY"
                    app:srcCompat="@drawable/onboarding_maybe"
                    app:backgroundTint="@android:color/transparent"
                    app:fabSize="normal"
                    app:borderWidth="0dp"
                    android:padding="0dp"
                    app:useCompatPadding="true"/>

            <android.support.design.widget.FloatingActionButton
                    android:id="@+id/like_button"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:scaleType="fitXY"
                    app:srcCompat="@drawable/onboarding_like"
                    app:backgroundTint="@android:color/transparent"
                    app:fabSize="normal"
                    app:borderWidth="0dp"
                    android:padding="0dp"
                    app:useCompatPadding="true"/>
        </LinearLayout>

        <in.zapr.onemedia.custom.ZTextView
                android:textAppearance="?android:textAppearanceSmall"
                android:id="@+id/tv_not_seen"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:textColor="@color/cs_not_seen"
                app:type_face="@string/font_heavy"
                android:text="@string/not_seen_text"
                android:layout_below="@id/ll_floating"/>

    </RelativeLayout>
    <in.zapr.onemedia.custom.ZButton
            android:id="@+id/ll_Next"
            android:layout_width="0dp"
            android:layout_height="70dp"
            app:layout_constraintRight_toRightOf="parent"
            app:layout_constraintLeft_toLeftOf="parent"
            app:layout_constraintBottom_toBottomOf="parent"
            android:background="@drawable/layout_click_selector"
            android:text="@string/letsGo"
            android:textAppearance="?android:textAppearanceMedium"
            android:textColor="@color/white"
            android:focusable="false"
            android:gravity="center"
            app:type_face="@string/font_black"/>

</android.support.constraint.ConstraintLayout>

这是问题 issue_image

我将输出xml output of the xml

我正在从这里使用CardStackView,

https://github.com/yuyakaido/CardStackView

1 个答案:

答案 0 :(得分:1)

尝试将这些属性添加到ll_cardViewroot_content_list

android:clipChildren="false" 
android:clipToPadding="false"