我已经在布局文件中创建了布局并定义了以下Xml
。DP在不同的屏幕上显示不同的布局
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.kirmani.myapplication.MainActivity"
android:orientation="vertical"
>
<ImageView
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="@color/colorPrimary"
/>
<ImageView
android:layout_width="match_parent"
android:layout_height="150dp"
android:background="@color/colorPrimaryDark"
/>
<ImageView
android:layout_width="405dp"
android:layout_height="260dp"
android:background="@color/colorAccent"
/>
</LinearLayout>
这是填充我的整个屏幕在Nexus 4
屏幕完美。但是当我预览所有的屏幕时,它在一些屏幕上显得非常奇怪。
我正在使用DP
,它应该保持相同的display
根据所有屏幕,但它不是那样工作。请指导我..
谢谢,这符合所有设备的宽度,但高度仍然是一个问题。在Nexus One中它会填满整个屏幕,但在其他屏幕中显示空间 - – Kirmani88
您可以在第3个图像视图中使用您的身高匹配父母也 – Masum