Android: 设置圆形进度条在布局中心
Android: Set Circular progressbar at the center of layout
进度条出现在布局的顶部中心,但我想将其对齐到布局的中心。我也在 Whosebug 上尝试过其他答案,但没有用。这是布局:
<?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>
<?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
可见性设置为可见
试试这个
<?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" />
进度条出现在布局的顶部中心,但我想将其对齐到布局的中心。我也在 Whosebug 上尝试过其他答案,但没有用。这是布局:
<?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>
<?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
可见性设置为可见
试试这个
<?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" />