我很困惑为什么属性clipChildren不能在RelativeLayout中工作但在LinearLayout中工作。 我将LinearLayout和RelativeLayout放在父RelativeLayout中。并将clipChildren设置为' false'这三种布局。但它显示出差异。 代码如下:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:clipChildren="false"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:clipChildren="false"
android:clipToPadding="false"
android:background="#ff0000"
android:layout_marginTop="200dp"
android:layout_width="100dp"
android:layout_height="200dp">
<Button
android:background="@color/colorPrimaryDark"
android:layout_width="300dp"
android:layout_height="100dp" />
</LinearLayout>
<RelativeLayout
android:clipChildren="false"
android:clipToPadding="false"
android:background="#ff0000"
android:layout_width="100dp"
android:layout_height="200dp">
<Button
android:background="@color/colorPrimaryDark"
android:layout_width="300dp"
android:layout_height="100dp" />
</RelativeLayout>
</RelativeLayout>
结果如下: image of result