【发布时间】:2017-01-11 12:53:31
【问题描述】:
我是 android 设计的新手,所以我希望我的主屏幕图像适合所有设备我希望这个 MainScreen 页面适合所有设备。它有 3 张我给权重的图像,但如果我在标签上测试它似乎没有任何效果。它看起来不像我想要的那样,这是图像
这是我的 XML。我知道我不应该给 dp 高度,而是如何让它看起来像这样而不给出尺寸。
<RelativeLayout 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.zeba.broccoli.MainActivity" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical"
android:layout_marginTop="50dp"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true">
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="1">
<ImageView
android:id="@+id/ms1"
android:layout_width="match_parent"
android:layout_height="374dp"
android:layout_weight="7"
android:scaleType="fitXY"
android:src="@drawable/avatar" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
>
<ImageView
android:id="@+id/ms2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitXY"
android:src="@drawable/ee"
android:layout_weight=".5" />
<ImageView
android:id="@+id/ms3"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitXY"
android:src="@drawable/dd"
android:layout_weight=".5" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
【问题讨论】:
-
图像的固定尺寸可能因设备而异。使用 wrap_content 作为尺寸,并告诉你的设计师根据不同的屏幕分辨率设计图像。
-
如果你不想给出尺寸,那么你需要将不同尺寸的图像放在单独的可绘制文件夹中,即drawable-xhdpi、drawable-xxhdpi等
-
如果我根据 hdpi、xxhdpi 等设备调整图像大小..就像那样..thn 它可以适合吗?
-
没关系,但是在这里我可以在不给出高度大小的情况下给我的图像完美的外观..例如,这里我给出了 374dp..我没有给出 shd
-
我想用重量来建造..但是重量在这里不起作用
标签: android android-layout android-imageview