2016-07-20 1 views
0

Dans un fichier de mise en page que je veux afficher une barre de progression et un webview swipeable. Si j'implémente la disposition de balayage, la barre de progression disparaît automatiquement et ne peut pas être affichée.barre de progression Android dans la disposition de balayage invisible

Quel est le problème?

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

Répondre

1

Il est parce que SwipeRefreshLayout couvre ProgressBar. Dans RelativeLayout, celui situé plus bas dans le Xml signifie plus haut dans l'axe Z.

Inverser l'ordre devrait fonctionner.

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