【发布时间】:2015-11-20 21:14:24
【问题描述】:
我们如何为 android 视图元素使用 percentage 值?像这样的
<TextView
android:id="@+id/"
android:layout_width="75%"
android:layout_height="50%"/>
【问题讨论】:
-
除了答案中引用的库之外,您可以在
LinearLayout中使用android:layout_weight来实现类似的目标:github.com/commonsguy/cw-omnibus/blob/master/Containers/… -
@CommonsWare 但是我们如何在单一布局中同时设置宽度和高度的百分比?
-
@Cyanotis:不,除了嵌套
LinearLayout容器并通过android:layout_weight沿两个轴控制百分比。毫无疑问,新的android.support.percent类更加灵活。我只是想指出经典的方法,因为有些人反对使用库。 -
@CommonsWare 好的。我以为还有其他方法。感谢重播。
标签: android android-view android-preferences android-styles