我的应用程序停止在SET RELATIVELAYOUT背景上工作



当将image作为RelatiVelayout中的映像作为背景时,该应用程序在设备中不起作用,尽管它在所有emulatur中工作 - 图像大小630*354 JPEG

<?xml version="1.0" encoding="utf-8"?>
<Relativelayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools: context="com.a7mad7assan.telwat.MainActivity"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/mini" >
</Relativelayout>

在此处输入图像描述

除了将图像变成九个补丁以外,我认为这是不可能的。相反,您可以做的是将ImageView添加为Relativelayout中的第一个视图。将layout_centerinparent设置为true,并将Layout_width和Layout_height设置为match_parent。然后将ScaleType设置为CenterCrop。这将确保图像填充屏幕而不会失真,但取决于屏幕尺寸/方向,可以切断图像的顶/底部或左/左/右。

<ImageView android:layout_width="match_parent" android:layout_height="match_parent" android:layout_centerInParent="true" android:scaleType="centerCrop" android:src="@drawable/background" />

相关性中的任何其他视图都将出现在图像视图的顶部,只要它是Relativelayout中的第一个视图(当您在XML中时(。

最新更新