首页 > 解决方案 > Android 视图 asbolute 超出父级

问题描述

我的问题是有没有办法让他的父母看到?我正在尝试这样做,但我不知道该怎么做

我尝试使用 RelativeLayout 和 ConstraintLayout 但我仍然无法工作......

                    </LinearLayout>

                <RelativeLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent">

                    <ImageView
                        android:id="@+id/card_promotion_image"
                        android:layout_width="128dp"
                        android:layout_height="110dp"
                        android:layout_marginTop="5dp"
                        android:layout_marginEnd="-20dp"
                        android:src="@drawable/im_carrying_letters" />
                </RelativeLayout>


            </androidx.constraintlayout.widget.ConstraintLayout>

我想要的是

我得到了什么

标签: javaandroidxmlkotlin

解决方案


如果您想将其水平移出其超级视图,请在代码中尝试修改translationX属性。如果要垂直移动它,请尝试修改translationZ属性。并且不要忘记将超级视图的clipToPaddingclipChildren属性设置为false,以便您移动的视图可以显示在其超级视图的边框之外


推荐阅读