Android 滑动布局中的进度条不可见
Android progressbar in swipe layout invisible
在一个布局文件中,我想显示一个进度条和一个可滑动的网络视图。
如果我实现滑动布局,进度条会自动消失并且无法显示。
有什么问题?
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:mlns="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.xy.MainActivity">
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/progressBarCenter"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:visibility="visible"
android:background="#ff0303" />
<android.support.v4.widget.SwipeRefreshLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:mlns="http://schemas.android.com/apk/res-auto"
android:id="@+id/swiper"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.xy.MainActivity">
<WebView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/webView"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
</android.support.v4.widget.SwipeRefreshLayout>
</RelativeLayout>
因为SwipeRefreshLayout
覆盖了ProgressBar
。在 RelativeLayout
中,在 Xml 中较低的位置表示在 Z 轴中较高的位置。
颠倒顺序应该可以。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:mlns="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.xy.MainActivity">
<android.support.v4.widget.SwipeRefreshLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:mlns="http://schemas.android.com/apk/res-auto"
android:id="@+id/swiper"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.xy.MainActivity">
<WebView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/webView"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
</android.support.v4.widget.SwipeRefreshLayout>
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/progressBarCenter"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:visibility="visible"
android:background="#ff0303" />
</RelativeLayout>
在一个布局文件中,我想显示一个进度条和一个可滑动的网络视图。 如果我实现滑动布局,进度条会自动消失并且无法显示。
有什么问题?
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:mlns="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.xy.MainActivity">
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/progressBarCenter"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:visibility="visible"
android:background="#ff0303" />
<android.support.v4.widget.SwipeRefreshLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:mlns="http://schemas.android.com/apk/res-auto"
android:id="@+id/swiper"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.xy.MainActivity">
<WebView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/webView"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
</android.support.v4.widget.SwipeRefreshLayout>
</RelativeLayout>
因为SwipeRefreshLayout
覆盖了ProgressBar
。在 RelativeLayout
中,在 Xml 中较低的位置表示在 Z 轴中较高的位置。
颠倒顺序应该可以。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:mlns="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.xy.MainActivity">
<android.support.v4.widget.SwipeRefreshLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:mlns="http://schemas.android.com/apk/res-auto"
android:id="@+id/swiper"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.xy.MainActivity">
<WebView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/webView"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
</android.support.v4.widget.SwipeRefreshLayout>
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/progressBarCenter"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:visibility="visible"
android:background="#ff0303" />
</RelativeLayout>