【发布时间】:2017-05-24 18:00:06
【问题描述】:
我想从我的图像中获得以下类型的背景:
这是不是重复的问题,因为我尝试了以下解决方案:
这些答案建议使用图像视图的以下属性:
android:scaleType="..."
我已经为此尝试了每个可用的值。我得到的是:
如果我使用android:scaleType="center",或者在中心有一个非常小的图像。
以下是我为此活动的布局文件:
<?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:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.admin.georeminder.MainActivity">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/view"
android:src="@mipmap/landscape"
android:scaleType="centerCrop" />
</RelativeLayout>
那么我在这里错过了什么?任何帮助将不胜感激!谢谢
编辑
我也尝试过以下组合:
android:scaleType="fitXY"
android:adjustViewBounds="true"
【问题讨论】:
-
宽度和高度不要使用
match_parent,而是使用wrap_content -
然后它在左上角显示非常小的图像。
-
这是因为图片尺寸(宽高)小于屏幕尺寸。您需要一个更大尺寸的图片图像文件。
-
不!图像尺寸为 4288*2848 像素。大小为 1.45 MB
-
您是在布局设计器上还是在设备上看到这个?此外,您应该将图像放置在 Res/drawable 中,而不是 Res/mipmap,mipmap 仅适用于应用启动器图标。
标签: android xml image android-layout