Android RelativeLayout 拉伸背景
Android RelativeLayout stretch background
全部。
这是我的布局代码:
<?xml version="1.0" encoding="utf-8"?>
<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"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:background="@mipmap/backgroung"
tools:context=".MainScreen">
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30pt"
android:text="@string/level1"
android:onClick="@string/level1"
android:id="@+id/level1"/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="60pt"
android:text="@string/level2"
android:id="@+id/level2"/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="90pt"
android:text="@string/level3"
android:id="@+id/level3"/>
看起来是:
我希望打孔照片在整个白色背景上伸展。
感谢各位帮手!
这里最好使用 9patch 图片。其中打孔区域可以是恒定的,图像可以随着蓝色区域拉伸。这样你就不会因为拉伸而面临图像模糊的问题。您可以从 youtube 上找到一些关于如何创建 9patch 的好例子。这是 sample。
在您的 RelativeLayout 中,您看到 android:paddingTop
和 bottom/left/right 了吗?删除所有这些或更改为 ="0dp"
.
将您的图片移至按钮前 <ImageView/>
。
并使用android:scaleType="fitXY"
哦,确保你的照片没有任何空白边框。
我明白了,
添加新图像资产时,它会调整图像大小并裁剪为带有白色边框。
需要硬拷贝-粘贴整张照片到drawable文件夹。
全部。 这是我的布局代码:
<?xml version="1.0" encoding="utf-8"?>
<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"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:background="@mipmap/backgroung"
tools:context=".MainScreen">
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30pt"
android:text="@string/level1"
android:onClick="@string/level1"
android:id="@+id/level1"/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="60pt"
android:text="@string/level2"
android:id="@+id/level2"/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="90pt"
android:text="@string/level3"
android:id="@+id/level3"/>
看起来是:
我希望打孔照片在整个白色背景上伸展。
感谢各位帮手!
这里最好使用 9patch 图片。其中打孔区域可以是恒定的,图像可以随着蓝色区域拉伸。这样你就不会因为拉伸而面临图像模糊的问题。您可以从 youtube 上找到一些关于如何创建 9patch 的好例子。这是 sample。
在您的 RelativeLayout 中,您看到 android:paddingTop
和 bottom/left/right 了吗?删除所有这些或更改为 ="0dp"
.
将您的图片移至按钮前 <ImageView/>
。
并使用android:scaleType="fitXY"
哦,确保你的照片没有任何空白边框。
我明白了, 添加新图像资产时,它会调整图像大小并裁剪为带有白色边框。 需要硬拷贝-粘贴整张照片到drawable文件夹。