gpt4 book ai didi

android - 如何将重心赋予 ScrollView 内的进度条?

转载 作者:行者123 更新时间:2023-11-29 01:14:44 24 4
gpt4 key购买 nike

我不知道我的代码有什么问题我无法将我的进度条中心放到屏幕上。这是我的 XML 代码,我只想在加载 webWiew 页面之前放置进度条。一切正常,但进度条不集中。

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:showIn="@layout/app_bar_aboutus">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical">

<ImageView
android:id="@+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="20dp"
app:srcCompat="@drawable/pinnainfotech_logo" />


<WebView
android:id="@+id/webview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"


android:layout_marginTop="0dp" />
<ProgressBar
android:layout_height="wrap_content"
android:layout_width="60dp"


android:gravity="center_vertical|center_horizontal"


android:id="@+id/progressBar1"/>



</LinearLayout>



</ScrollView>

最佳答案

让你的进度条远离 ScrollView ,原因: ScrollView 时,进度条应始终位于中心。

我已经编辑了你的 xml View ,它看起来像这样。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ProgressBar
android:id="@+id/progressBar1"
android:layout_width="60dp"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true" />

<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
app:layout_behavior="@string/appbar_scrolling_view_behavior">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical">

<ImageView
android:id="@+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="20dp"
app:srcCompat="@drawable/pinnainfotech_logo" />

<WebView
android:id="@+id/webview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="0dp"
android:gravity="center" />
</LinearLayout>
</ScrollView>

关于android - 如何将重心赋予 ScrollView 内的进度条?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40583845/

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