2016-09-28 55 views
1

进度条出现在布局的顶部中心,但我想将其与布局中心对齐。我也尝试了Stackoverflow上的其他答案,但它没有奏效。这里是布局:Android:在布局的中心设置圆形进度条

<?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/progressbar" 
    android:layout_width="30dp" 
    android:layout_height="30dp" 
    android:layout_centerInParent="true" 
    android:layout_centerHorizontal="true" 
    android:layout_centerVertical="true"/> 

    <android.support.v7.widget.RecyclerView 
    android:id="@+id/dashboard_recyclerview" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:scrollbars="vertical" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior"/> 

</RelativeLayout> 
+0

@Bansal REA问题。他已经申请了。 –

回答

2

试试这个

<?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"> 

<android.support.v7.widget.RecyclerView 
    android:id="@+id/dashboard_recyclerview" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:scrollbars="vertical" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior" /> 

<ProgressBar 
    android:id="@+id/progressbar" 
    android:layout_width="30dp" 
    android:layout_height="30dp" 
    android:layout_centerInParent="true" /> 

+0

layout_height =“match_parent”recyclerview运作良好。谢啦!! –

1
<?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/progressbar" 
     android:layout_width="30dp" 
     android:layout_height="30dp" 
     android:layout_centerInParent="true"/> 

    <android.support.v7.widget.RecyclerView 
     android:id="@+id/dashboard_recyclerview" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:visibility="gone" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior"/> 

</RelativeLayout> 

让您recyclerview能见度,前面走了,当你获取数据,你获取数据,然后设置progressbar能见度消失了,recyclerview可见性可见

+0

仍然没有工作.. –

+0

我已经在relativelayout中尝试过centerInParent =“true”,但它仍然不能正常工作 –

+0

@Androidjack是你的布局是主布局,或者它是其他布局的子集。因为它可能在我的设备上工作得很好 – Nikhil