ViewStub布局生效小结

viewStub 直接layout的布局最外层设置的 margin属性不生效

viewStub设置的margin属性在preview 中不能直观看到,但在手机中run是正常显示

preview效果:

ViewStub布局生效小结_第1张图片

frame_layout1.xml

xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginLeft="30dp"
    android:layout_marginTop="30dp"
    android:background="@android:color/darker_gray">

            android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="parent set up margin ,it doesn't work" />

frame_layout2.xml

xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@android:color/darker_gray">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="view stub set up margin ,it work" />
手机效果图:

ViewStub布局生效小结_第2张图片

你可能感兴趣的:(ViewStub布局生效小结)