我试图调整我的布局,如材料设计的Metrics和Keylines网页所示,
无法弄清楚如何将其应用到我的布局中,我该如何在xml中执行此操作?谢谢你的帮助
答案 0 :(得分:2)
如果没有要使用所需宽高比的图像(或者不需要图像),则可以使用占位符。例如,我创建了一个尺寸为16px×9px的可绘制形状,并用它来调整相对布局的边界:
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:src="@drawable/ratio16x9"/>
</RelativeLayout>
ratio16x9.xml:
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<size android:width="16px" android:height="9px"/>
</shape>