android - 在Android中居中背景图像

标签 android background orientation center

我有一个大约 100 x 100 的背景图片,我想在 Android 应用程序中居中。有没有办法做到这一点?

我认为这将对简单应用的方向更改有很大帮助。

最佳答案

您可以使用 BitmapDrawable 的情况。在 res/drawable 文件夹中创建 centered.xml:

<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
    android:src="@drawable/your_image"
    android:gravity="center"/>

然后你可以使用 centered drawable 作为背景。

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

相关文章:

android - 从服务发送广播到 Activity ?

javascript - 在 Javascript 上使用 Rhino 的 evaluateString() 的 Android StackOverflow 错误

html - "Background-Image"不能在 CSS 中使用 "height:auto"?

ios - 在 iOS 7.1 中强制横向方向工作,而不是 iOS 8.0

android - 无法使用 RoomDatabase.query 更新 sqlite_sequence 表

android - Android 内存不足字符串

css - Wordpress ACF Repeater 背景图片只加载最后一张图片

Android:在空白 Activity 区域启用点击事件

android - 重新映射传感器坐标

c# - 如何确定三角形的方向/旋转?