【发布时间】:2019-02-18 02:31:52
【问题描述】:
所以我有一个RelativeLayout,我在其中放置了两个ImageView,一个作为背景图像,另一个在中间,但稍微靠近底部(见下图)。我有所有 6 种密度的图像。我的问题是,如果我将它拖到我想要的位置,它对于所有密度来说看起来都不一样。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:scaleType="centerCrop"
android:src="@drawable/background" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="87dp"
android:scaleType="centerCrop"
android:src="@drawable/img2" />
</RelativeLayout>
【问题讨论】:
-
如果你想要一个背景图像,将其设置为
RelativeLayout,然后使用另一个图像视图作为图像持有者。 “所有密度看起来都不一样”是什么意思 -
如果我将第二个 ImageView 拖到我想要的位置,hdpi 中的外观与 xxhdpi 中的不同。而且我在单独的可绘制文件夹中有所有密度的不同图像。
-
My problem is if I drag it to place it where I want it to be it doesn't look the same for all densities- 你想把它放在哪里?
标签: android html layout background