gpt4 book ai didi

Android ProgressBar .xml 布局

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:43:50 24 4
gpt4 key购买 nike

我有一个 XML 文件:

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

<ProgressBar
android:id="@+id/progressbar"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:visibility="visible" />

<WebView
android:id="@+id/web_engine"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:visibility="gone" />

</LinearLayout>

我希望 ProgressBarLarge 样式,并在屏幕中间垂直和水平居中...当我设置 layout_width heightfill_parent,它将实际加载微调器的大小增加到整个屏幕...如何使布局适合整个屏幕并将实际加载图标居中?

最佳答案

我检查了几种可能性,根据我的经验,此类任务的最佳选择是:

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

<ProgressBar
android:id="@+id/progressbar"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:visibility="visible" />

<WebView
android:id="@+id/web_engine"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:visibility="gone" />

</RelativeLayout>

我将 RelativeLayoutandroid:layout_centerInParent="true" 一起使用,它比 LinearLayout 效果更好。

干杯

关于Android ProgressBar .xml 布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12290627/

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