android - Activity 中的全屏背景图像

标签 android background imageview android-framelayout

我看到许多使用全屏图像作为背景的应用程序。 这是一个例子:

Full screen background image

我想在项目中使用它,到目前为止我发现的最好方法是使用大尺寸的图像,将其放入 ImageView 并使用 android:adjustViewBounds="true" 调整边距

问题是,如果屏幕的分辨率非常高,图像就会不足。

我想到的另一个选择是在 FrameLayout 中使用图像,match_parentwidthheight > 作为背景...这会拉伸(stretch)图像,但我认为效果不是很好。

你会怎么做?

最佳答案

有几种方法可以做到。

选项 1:

为不同的dpi创建不同的完美图像并将它们放置在相关的drawable文件夹中。然后设置

android:background="@drawable/your_image"

选项 2:

添加单个大图像。使用框架布局。作为第一个 child 添加一个 ImageView。在 ImageView 中设置以下内容。

android:src="@drawable/your_image"
android:scaleType = "centerCrop"

关于android - Activity 中的全屏背景图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16135984/

相关文章:

Android 从类开始 Activity

css - 打印具有线性渐变和边框的 CSS 对象时,线性渐变背景消失

css - 更改 Bootstrap 导航 a :active background color

java - 带有俄语网址的 ImageView

android - 如何在 android studio 中为 multiResolution 定义维度

android - 清除 AdMob 在 Android 中生成的缓存文件是一种好习惯吗?

android - 如何修复我的 android 照片上传以发送更大的数据流

ios - 让应用程序在后台执行一个功能

swift - 如何将图像连接到另一个 ViewController 并将其显示在 ImageView 中?

android - View 中的 ImageView setImageBitmap()