2016-09-28 15 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レアDの質問。彼はすでにそれを適用しました。 –

答えて

2

としてrecyclerview視認性が

これを試してみてくださいとあなたの recyclerview可視性を確認します
<?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

recyclerviewのlayout_height = "match_parent"はうまくいきました。ありがとう!! –

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> 

あなたがデータをフェッチする際に、以前に行って、あなたがデータをフェッチした後、その後消えてprogressbar可視性を設定し、可視

+0

まだ動作していません.. –

+0

relativelayoutで既にcenterInParent = "true"を試しましたが、まだ動作していません。 –

+0

@Androidjackはあなたのレイアウトがメインレイアウトか、他のレイアウトの子です。どのように私のデバイスで完璧に動作する可能性があるので、 – Nikhil

関連する問題