viewStub 直接layout的布局最外层设置的 margin属性不生效
viewStub设置的margin属性在preview 中不能直观看到,但在手机中run是正常显示
preview效果:
frame_layout1.xml
<FrameLayout 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"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="parent set up margin ,it doesn't work" /> </FrameLayout>
frame_layout2.xml
<FrameLayout 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" /> </FrameLayout>手机效果图: