歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux編程 >> Linux編程 >> Android LineaerLayout中layout_margin失效不起作用的解決方法

Android LineaerLayout中layout_margin失效不起作用的解決方法

日期:2017/3/1 10:17:02   编辑:Linux編程

Android LineaerLayout中layout_margin失效不起作用的解決方法:

  1. <LinearLayout
  2. android:id="@+id/main"
  3. android:layout_width="fill_parent"
  4. android:layout_height="wrap_content"
  5. android:layout_margin="20dp"
  6. android:orientation="vertical">

上面這種做法在某些Android版本放到scrollview或者RelativeLayou裡面的話,layout_margin會失效,不起作用!

網上沒找到相關解決方案,只能自己摸索,設置各種屬性,最後終於解決:

在屬性裡面加入android:layout_gravity="top",問題就解決了,我覺得這個是android的一個bug。

Copyright © Linux教程網 All Rights Reserved