gpt4 book ai didi

java - 使用RelativeLayout来偏移中心对齐ProgressBar View ?

转载 作者:行者123 更新时间:2023-12-01 10:05:11 24 4
gpt4 key购买 nike

我有一个 ImageView 作为图像的背景,同时有一个预加载器在屏幕中心水平和垂直对齐。我设法将进度条居中,但无法使用边距将其稍微偏移到上方。

有些人建议使用 linearLayout 并使用 android:layout_weight 进行控制,但是它对我不起作用,因为我需要将图像应用为背景,因此相对布局...

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:background="#FE6869"
android:weightSum="1">

<ImageView
android:src="@drawable/splashscreen"
android:scaleType="centerCrop"
android:layout_width="match_parent"
android:layout_height="match_parent" />


<ProgressBar
android:id="@+id/loading_spinner"
style="@style/Widget.AppCompat.ProgressBar"
android:layout_width="65dp"
android:layout_height="65dp"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="170dp" />


</RelativeLayout >

最佳答案

试试这个。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:background="#FE6869"
android:weightSum="1">

<ImageView
android:src="@drawable/splashscreen"
android:scaleType="centerCrop"
android:layout_width="match_parent"
android:layout_height="match_parent" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ProgressBar
android:id="@+id/loading_spinner"
style="@style/Widget.AppCompat.ProgressBar"
android:layout_width="65dp"
android:layout_height="65dp"
android:layout_weight="1"
android:layout_marginTop="170dp" />
</LinearLayout>
</RelativeLayout >

关于java - 使用RelativeLayout来偏移中心对齐ProgressBar View ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36529152/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com