简体   繁体   English

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

[英]Constraint Layout - How to make an image view (frame) to move on whole screen

I have a constraint layout with card view like tinder. 我有一个像火种一样的卡片视图约束布局。 I have changed the size of that view and like can move (like/dislike). 我已经更改了该视图的大小,并且可以移动(喜欢/不喜欢)。 But image is getting cut(since its in the inner frame). 但是图像被剪切了(因为它在内部框架中)。 I want to move the frame on whole screen manually. 我想在整个屏幕上手动移动框架。

Here is the layout file 这是布局文件

<?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>

And this is the issue 这就是问题 issue_image

The output of xml will me xml的输出将我 xml的输出

I am using the CardStackView from here, 我在这里使用CardStackView

https://github.com/yuyakaido/CardStackView https://github.com/yuyakaido/CardStackView

Try to add to ll_cardView and root_content_list this attributes 尝试添加到ll_cardViewroot_content_list此属性

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使图像视图适合屏幕的片段布局/约束或框架布局/ - how to make an imageview fits the screen in fragment layout / constraint or frame layout / 如何在图像视图的右侧放置文本视图而不重叠它并在约束布局中覆盖整个宽度 - How to place text view on right side of image view without overlapping it and covering whole width in constraint layout 如何在约束布局中以编程方式移动视图(按钮)? - How to move a view (button) programmatically in a constraint layout? 将视图移出约束布局 - Move View out of Constraint Layout 如何使视图覆盖整个屏幕? - How to make the View to cover the whole screen? 如何在Android中使图像适合整个屏幕? - How to make image fit the whole screen in android? 如何获得scrollView中的帧布局的所有视图的整个位图 - how to get whole bitmap of all view of frame layout which is in scrollView 如何使用约束布局制作像这张图片这样的布局 - How to make a layout like this image using constraint layout position如何在Android开始时约束布局在屏幕外 - How to position a view in Android constraint layout outside the screen at the beginning 如何调整约束布局以滚动视图以适合所有屏幕? - How to adjust constraint layout to scroll view to fit all screen?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM