2016-07-20 37 views
0

In einer Layoutdatei möchte ich eine Fortschrittsanzeige und eine swipeable Webview zeigen. Wenn ich das Wischlayout implementiere, verschwindet die Fortschrittsleiste automatisch und kann nicht angezeigt werden.Android Fortschrittsbalken in Swipe-Layout unsichtbar

Was ist das Problem?

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

Antwort

1

Es ist, weil SwipeRefreshLayout ist ProgressBar abdeckt. In RelativeLayout bedeutet der, der im Xml unten liegt, höher in der Z-Achse.

Umgekehrt sollte die Reihenfolge funktionieren.

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