我看到许多使用全屏图像作为背景的应用程序。 这是一个例子:
我想在项目中使用它,到目前为止我发现的最好方法是使用大尺寸的图像,将其放入 ImageView
并使用 android:adjustViewBounds="true"
调整边距
问题是,如果屏幕的分辨率非常高,图像就会不足。
我想到的另一个选择是在 FrameLayout
中使用图像,match_parent
在 width
和 height
> 作为背景...这会拉伸(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/