show progress bar center of screen

前端 未结 2 1186
旧巷少年郎
旧巷少年郎 2021-01-23 07:43

I using a progress bar inside my layout. When I start the app the progress bar is always aligned to top left corner of screen. Below is my xml layout file. how can I align it o

相关标签:
2条回答
  • 2021-01-23 08:06

    Remove Progress bar from ScrollView and place it as the first child of parent layout and use android:layout_centerInParent="true"

      <RelativeLayout 
            xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:tools="http://schemas.android.com/tools"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:id="@+id/relativeLayout1"
            android:orientation="vertical"    
            android:background="#F1F1F1">
    
             <ProgressBar
                android:id="@+id/progressBar"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"    
                android:indeterminateDrawable="@drawable/my_progress_indeterminate"
                android:layout_centerInParent="true" >
             </ProgressBar>
    
            <ScrollView
                android:layout_width="fill_parent"
                android:layout_height="fill_parent" >
                <LinearLayout 
                   android:layout_width="fill_parent"
                   android:layout_height="fill_parent"
                   android:orientation="vertical"
                   android:id="@+id/scrolllinear">
    
    0 讨论(0)
  • 2021-01-23 08:07

    To center it try in your progress bar area.

    android:gravity="center"
    
    0 讨论(0)
提交回复
热议问题