首页 > 解决方案 > 如何将项目位置设置为底部中心 launchbackground.xml

问题描述

我试图在我的应用启动画面中添加一个图像,但我不知道如何将它的重力设置为底部中心。有我的代码:

<item
    android:width="265dp"
    android:height="160dp"
    android:drawable="@mipmap/bottomsplash"
    android:gravity="bottom" />

底部重力将其设置在左下方,但我希望它位于底部中心。

标签: androidxmlflutterkotlinsplash-screen

解决方案


尝试这个 :

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <ImageView
        android:width="265dp"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:height="160dp"
        android:drawable="@mipmap/bottomsplash"
        android:layout_marginBottom="50dp" />

</RelativeLayout>

推荐阅读