2016-07-20 7 views
0

В одном файле макета я хочу показать панель прогресса и swipeable webview. Если я реализую макет прокрутки, индикатор прогресса автоматически исчезает и не может быть показан.Панель прогресса Android в макете прокрутки невидимая

В чем проблема?

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

ответ

1

Это происходит потому, что 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> 

 Смежные вопросы

  • Нет связанных вопросов^_^