这个问题可能会被要求超过1000次,我仍然在这里困惑,这将是正确的方法吗?当我谷歌搜索时,我发现了一些相关的链接link1, link2,link3 etc.解决方案我发现是使用xml中的相对布局design.All布局将位于layout文件夹中(如果您正在创建电话应用程序),并且尺寸应该在dimens.xml(位于values-mdpi,hdpi,xhdpi,xxhdpi,xxxhdpi文件夹中)中给出以支持所有屏幕。如何在android中创建应该支持所有设备的布局?
我该如何给图像视图的marginTop。我做这样的计算:在比率 (1:1.5:2:3:4) - (mdpi:hdpi:xhdpi:xxhdpi:xxxhdpi) - (10dp -15dp-20dp-30DP-40dp)。 我的方法是正确的还是?
我在drawable(mdpi:hdpi:xhdpi:xxhdpi:xxxhdpi)文件夹中给出了不同分辨率的不同图像。
我的问题是在values-mdpi/dimens.xml-margintop-10dp, values-hdpi/dimens.xml-margintop-15dp,values-xhdpi/dimens.xml-margintop-20dp等。不同的屏幕比例(1:1.5:2:3:4)是正确的? main.xml中:
<RelativeLayout
android:id="@+id/rl_submain"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<ImageView
android:id="@+id/iv_papa"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="@dimen/s_mtop"
android:background="@drawable/papa1"
android:gravity="center"/>
<TextView
android:id="@+id/tv_power"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:layout_marginBottom="@dimen/s_mbot"
android:textSize="12sp"
android:textColor="@color/white"
android:layout_alignParentBottom="true"
android:text="@string/poweredby"/>
</RelativeLayout>
<resources>
<!--Splash-->mdpi
<dimen name="s_mtop">10dp</dimen>
<dimen name="s_mbot">2dp</dimen>
<resources>
<!--Splash-->hdpi
<dimen name="s_mtop">15dp</dimen>
<dimen name="s_mbot">3dp</dimen>
<resources>
<!--Splash-->xhdpi
<dimen name="s_mtop">20dp</dimen>
<dimen name="s_mbot">4dp</dimen>
<resources>
<!--Splash-->xxhdpi
<dimen name="s_mtop">30dp</dimen>
<dimen name="s_mbot">6dp</dimen>
<resources>
<!--Splash-->xxxhdpi
<dimen name="s_mtop">40dp</dimen>
<dimen name="s_mbot">8dp</dimen>
您是否考虑过为不同屏幕尺寸创建资源?例如layout-sw300dp,layoutsw400dp,layout-sw600dp?布局sw800dp?然后很容易看到600和800覆盖平板电脑 – Eenvincible
[Android可以高效地加载图像]可能重复(http://stackoverflow.com/questions/32665582/android-load-images-from-drawable-efficiently) – YUVRAJ
@murugalonger我不认为这个问题涉及从drawables文件夹加载图像;它是关于支持布局中的所有屏幕尺寸/设备 – Eenvincible