Java Android视图从父视图中删除
我的问题是,这是否存在一种让他父母看不见的方式? 我正试着这么做,但我不知道怎么做 我尝试使用RelativeLayout和ConstraintLayout,但我仍然无法使用Java Android视图从父视图中删除,java,android,xml,kotlin,Java,Android,Xml,Kotlin,我的问题是,这是否存在一种让他父母看不见的方式? 我正试着这么做,但我不知道怎么做 我尝试使用RelativeLayout和ConstraintLayout,但我仍然无法使用 </LinearLayout> <RelativeLayout android:layout_width="match_parent"
</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>
如果要将其水平移出超级视图,请在代码中尝试修改translationX属性。如果要垂直移动,请尝试修改translationZ属性。另外,不要忘记将超级视图的CliptPadding和clipChildren属性设置为false,以便移动的视图可以显示在超级视图的边框之外
FrameLayout
有助于将视图堆叠在一起,以便在视图中替换RelativeLayout
使用FrameLayout
您的XML将是:
</LinearLayout>
<FrameLayout
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" />
</FrameLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
用FrameLayout替换RelativeLayout我的天哪,就是这么简单。。。谢谢你的帮助