2014-12-17 3 views
2

Я пытаюсь реализовать SwipeRefreshLayout для плавающей кнопки и scrollview с тремя таблицами. Я хочу показать Floating Button все время на экране (например, в приложении Gmail с Material Design). К сожалению, обновление прокрутки блокирует прокрутку. Как сообщить об обновлении салфетки, чтобы моя прокрутка просмотрела прокрутку вверх? Должен ли я изменить структуру раскладки?SwipeRefresh с ScrollView и FloatingActionButton

Я использую библиотеку https://github.com/futuresimple/android-floating-action-button

Вот мой макет:

<android.support.v4.widget.SwipeRefreshLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:fab="http://schemas.android.com/apk/res-auto" 
android:id="@+id/swipe_container" 
android:layout_width="match_parent" 
android:layout_height="match_parent"> 

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <ScrollView 
     android:id="@+id/scroll_recent" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:orientation="vertical"> 

      <TableLayout 
       android:id="@+id/table_recent_claims" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content"></TableLayout> 

      <TableLayout 
       android:id="@+id/table_recent_rapidscans" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content"></TableLayout> 

      <TableLayout 
       android:id="@+id/table_recent_journeys" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content"></TableLayout> 
     </LinearLayout> 
    </ScrollView> 

    <com.getbase.floatingactionbutton.FloatingActionButton 
     android:id="@+id/fab" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="bottom|right" 
     fab:fab_icon="@drawable/fab_plus24" /> 
</FrameLayout> 
</android.support.v4.widget.SwipeRefreshLayout> 

ответ

0

Вам необходимо переопределить метод canChildScrollUp() программно для SwipeRefreshLayout. Каждый случай отличается, в зависимости от вида ребенка, который у вас есть под номером SwipreRefreshLayout.

Кроме того, я считаю, что FrameLayout ненужно в вашем случае, и может быть перехват scrollability в ScrollView

Google предлагает некоторые образцы для обоего ресурсов и коды, которые могут быть использованы для правильной реализации SwipeRefreshLayout:

Один вид: https://developer.android.com/samples/SwipeRefreshListFragment/index.html

Несколько просмотров: https://developer.android.com/samples/SwipeRefreshMultipleViews/index.html

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