我正在尝试将我的进度条居中在fragements屏幕中。以下是我迄今为止尝试过,在我看来有什么建议立即进行删除是正确的:居中进度条
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical">
<ProgressBar
android:id="@+id/pgFragment"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"/>
</LinearLayout>
<ScrollView
android:id="@+id/scrollView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone">
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:listitem="@layout/recycler_row" />
</ScrollView>
</LinearLayout>
我试图删除包装设计,摆脱了整个ScrollView
(但随着visibility
设置为gone
,它不该”问题)。目前的结果是,ProgressBar
粘在屏幕的顶部。
可能是因为活动布局实施NestedScrollView
?
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.mediasaturn.productlistpoc.activities.MainActivity"
tools:showIn="@layout/activity_main">
<fragment android:name="com.productlistpoc.recyclerview.RecyclerViewFragment"
android:id="@+id/fragment_recycler"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:layout="@layout/fragment_recycler" />
</android.support.v4.widget.NestedScrollView>
让父布局相对布局 –
然后呢?只有这不会改变任何东西。将根布局和进度条父级更改为相对 – 4ndro1d
并使进度条父级线性布局:centerinparent = true –