【问题标题】:Progress bar on centre in relative layout相对布局中心的进度条
【发布时间】:2014-08-23 19:59:27
【问题描述】:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="?android:attr/actionBarSize"
android:background="@drawable/stalker_background"
android:focusableInTouchMode="true" >


<ProgressBar 
    android:id="@+id/pb"
    android:layout_height="75dp"
    android:layout_width="75dp"
    android:layout_gravity="center"
    android:indeterminate="true"      
    />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">

<ScrollView 
    android:id="@+id/svProfile"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    >

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

<android.support.v4.view.ViewPager
                android:id="@+id/VPSlider"
                android:layout_width="match_parent"
                android:layout_height="175dp"
            />


            <android.support.v4.app.FragmentTabHost
                android:id="@android:id/tabhost"
                android:layout_width="match_parent"
                android:layout_height="match_parent" >

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

                    <TabWidget
                    android:id="@android:id/tabs"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="horizontal" />

                    <FrameLayout
                    android:id="@android:id/tabcontent"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent" />

                </LinearLayout>

                </android.support.v4.app.FragmentTabHost>       

</LinearLayout>
</ScrollView>
</LinearLayout>

</RelativeLayout>

进度条出现在屏幕的一角,我怎样才能将它对齐到屏幕的中心。我有相对的布局,当我在屏幕上显示一些东西后,我将删除这个进度条,这就是为什么我需要在其他控件之上使用它。

【问题讨论】:

    标签: android alignment android-relativelayout


    【解决方案1】:

    试试这个..

    android:layout_centerInParent="true" 添加到您的ProgressBar,因为您的父布局是RelativeLayout

    <ProgressBar 
        android:id="@+id/pb"
        android:layout_height="75dp"
        android:layout_width="75dp"
        android:layout_gravity="center"
        android:indeterminate="true"      
        android:layout_centerInParent="true"
        />
    

    【讨论】:

    • 对不起,我写错了,我在我的问题中添加了更多代码。我希望进度条位于 viewPager 的中心
    • @Yawar 然后在ViewPager 中给出ProgressBar 的内容布局。
    • 完成了,但没有显示出来。可能是在viewpager的后面。如果 viewPager 在它下面,我怎么能把它放在它上面。?
    • @Yawar 不不,我告诉你把ProgressBar 放在ViewPager 第一个项目布局中。
    【解决方案2】:

    试试这个方法,希望能帮助你解决问题。

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginTop="?android:attr/actionBarSize"
        android:background="@drawable/stalker_background"
        android:focusableInTouchMode="true" >
    
    
        <ProgressBar
            android:id="@+id/pb"
            android:layout_height="75dp"
            android:layout_width="75dp"
            android:layout_centerInParent="true"
            android:indeterminate="true"/>
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">
    
            <ScrollView
                android:id="@+id/svProfile"
                android:layout_width="match_parent"
                android:layout_height="match_parent">
    
                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="vertical" >
    
                </LinearLayout>
            </ScrollView>
        </LinearLayout>
    
    </RelativeLayout>
    

    【讨论】:

      猜你喜欢
      • 2018-12-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-05-04
      • 1970-01-01
      • 1970-01-01
      • 2015-02-27
      • 1970-01-01
      相关资源
      最近更新 更多