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 on centre of the screen. !!
<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">
<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">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/LinearLayout1"
android:orientation="vertical"
android:visibility="gone" >
<RelativeLayout android:id="@+id/layout_category1"
android:padding="10.0dip"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10.0dip"
android:layout_marginTop="10.0dip"
android:layout_marginRight="10.0dip"
android:clickable="false"
android:descendantFocusability="blocksDescendants">
<ImageView
android:id="@+id/more_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:src="@drawable/more"/>
<TextView android:textSize="28.0sp"
android:id="@+id/tv_category1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="more 1"
android:layout_toLeftOf="@id/tv_see_more_1"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true">
</TextView>
</RelativeLayout>
<horizontalscrollview
android:id="@+id/HMscrollView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/layout_category1">
<LinearLayout
android:id="@+id/myLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_margin="5dp">
</LinearLayout>
</horizontalscrollview>
</LinearLayout>
<LinearLayout
android:id="@+id/progLayout"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@null"
android:visibility="gone"
android:layout_gravity="center">
**<ProgressBar
android:id="@+id/progressBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:indeterminateDrawable="@drawable/my_progress_indeterminate" >
</ProgressBar>**
</LinearLayout>
<TextView
android:id="@+id/CheckTest"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="try again."
android:visibility="gone"
android:textSize="25.0sp"
android:textStyle="bold"
android:layout_marginTop="130dp"
></TextView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="@+id/LinearLayout2"
android:visibility="gone" >
<RelativeLayout android:id="@+id/layout_category2"
android:padding="10.0dip"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10.0dip"
android:layout_marginTop="10.0dip"
android:layout_marginRight="10.0dip">
<ImageView
android:id="@+id/tv_see_more_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:src="@drawable/more"/>
<TextView android:textSize="28.0sp"
android:id="@+id/tv_category2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="@id/tv_see_more_2"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true">
</TextView>
</RelativeLayout>
<horizontalscrollview
android:id="@+id/scrollViewHM2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/layout_category2">
<LinearLayout
android:id="@+id/myLayout2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
</LinearLayout>
</horizontalscrollview>
</LinearLayout>
</LinearLayout>
</ScrollView>
</RelativeLayout>
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…