Android在Layout中支持百分比
Android Layout終于支持百分比了
依賴
xml dependencies { compile 'com.android.support:percent:22.2.0' }
示例
```xml<android.support.percent.PercentRelativeLayout xmlns:app="<View android:id="@+id/relative_top" android:layout_width="0dp" android:layout_height="0dp" android:layout_alignParentTop="true" android:background="#000000" app:layout_heightPercent="30%" app:layout_widthPercent="100%" /> <android.support.percent.PercentFrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/relative_middle" android:layout_width="0dp" android:layout_height="0dp" android:layout_below="@+id/relative_top" android:background="#0000ff" app:layout_heightPercent="40%" app:layout_widthPercent="50%"> <View android:id="@+id/frame_0" android:layout_width="0dp" android:layout_height="0dp" android:background="#00ffff" app:layout_heightPercent="25%" app:layout_widthPercent="75%" app:layout_marginTopPercent="75%" app:layout_marginLeftPercent="25%"/> <View android:id="@+id/frame_1" android:layout_width="0dp" android:layout_height="0dp" android:background="#ffff00" app:layout_heightPercent="75%" app:layout_widthPercent="25%" /> </android.support.percent.PercentFrameLayout> <View android:id="@+id/relative_bottom" android:layout_width="0dp" android:layout_height="0dp" android:layout_below="@id/relative_middle" android:background="#00ff00" app:layout_heightPercent="30%" app:layout_widthPercent="100%" />
</android.support.percent.PercentRelativeLayout> </RelativeLayout></pre>
```
支持屬性
- layout_widthPercent
- layout_heightPercent
- layout_marginPercent
- layout_marginLeftPercent
- layout_marginTopPercent
- layout_marginRightPercent
- layout_marginBottomPercent
- layout_marginStartPercent
- layout_marginEndPercent
</ul> 來自: http://lusfold.github.io/android/2015/07/05/Android%E5%9C%A8Layout%E4%B8%AD%E6%94%AF%E6%8C%81%E7%99%BE%E5%88%86%E6%AF%94.html
本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!