Wie, um den Bildlauf nach oben/unten von der unteren Leiste zum scrollen der RecyclerView
Mit Google die jüngste Version der Design-Bibliothek Unterstützt einige Coole neue Ansichten vorgestellt worden. Mit einigen der neuen Komponenten (z.B. CoordinatorLayout ) könnte (!) aktivieren Sie erreichen das scrolling-Verhalten.
War ich tryed mit einigen eingebauten scrolling-Verhalten aber nichts funktioniert für mich,
Ich habe eine bottombar(LinearLayout) in mein layout in platzieren von FloatingActionButton
Hier, was ich will.
- OnLaunch dieser Bildschirm unteren Leiste erscheinen soll.
- Auf scrollup der recyclerview unteren Leiste sollte scrolldown.
- Auf scrolldown der recyclerview unteren Leiste sollte scrollup
Gibt es eine eingebaute Mechanismus, um dies zu erreichen ? oder müssen Wir das schreiben von java-code?
Hier ist mein code:
main_activty.xml
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<include layout="@layout/toolbar_srp" />
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:elevation="5dp"
app:tabGravity="fill"
app:tabIndicatorColor="@android:color/white"
app:tabMode="fixed" />
</android.support.design.widget.AppBarLayout>
<!-- All Scrollable Views -->
<android.support.v4.view.ViewPager
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
<!-- Bottom bar-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="#a0000000"
android:orientation="horizontal"
android:paddingBottom="@dimen/padding_small"
android:paddingTop="@dimen/padding_small">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.33"
android:gravity="center"
android:paddingBottom="@dimen/padding_small"
android:paddingTop="@dimen/padding_small"
android:text="AC"
android:textColor="@color/white" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.33"
android:gravity="center"
android:paddingBottom="@dimen/padding_small"
android:paddingTop="@dimen/padding_small"
android:text="Sleeper"
android:textColor="@color/white" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.33"
android:gravity="center"
android:paddingBottom="@dimen/padding_small"
android:paddingTop="@dimen/padding_small"
android:text="Premium"
android:textColor="@color/white" />
</LinearLayout>
</android.support.design.widget.CoordinatorLayout>
fragment.xml (hier war ich geputtet meine recyclerview code)
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingBottom="@dimen/padding_small"
android:paddingTop="@dimen/padding_small"
android:weightSum="1">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.33"
android:background="@drawable/bg_srp_sorter"
android:clickable="true"
android:gravity="center"
android:paddingBottom="@dimen/padding_small"
android:paddingTop="@dimen/padding_small"
android:text="Departure" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.33"
android:background="@drawable/bg_srp_sorter"
android:gravity="center"
android:paddingBottom="@dimen/padding_small"
android:paddingTop="@dimen/padding_small"
android:text="Duration" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.33"
android:gravity="center"
android:paddingBottom="@dimen/padding_small"
android:paddingTop="@dimen/padding_small"
android:text="Price" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/lite_gray"></View>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:weightSum="1">
<android.support.v7.widget.RecyclerView
android:id="@+id/bus_list_recycler_view"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
</LinearLayout>
</LinearLayout>
toolbar.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorPrimary"
app:layout_scrollFlags="scroll|enterAlways"
android:minHeight="?attr/actionBarSize">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="1">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.10">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/abc_ic_ab_back_mtrl_am_alpha" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.78"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="1">
<TextView
android:id="@+id/toolbar_title_source"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.47"
android:ellipsize="end"
android:singleLine="true"
android:text="Thiruvananthapuram "
android:textColor="@color/white"
android:textSize="@dimen/label_text_size_large" />
<TextView
android:id="@+id/toolbar_title_arrow"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.08"
android:text="@string/char_right"
android:textColor="@color/white"
android:textSize="@dimen/label_text_size_large"
android:textStyle="bold" />
<TextView
android:id="@+id/toolbar_title_destination"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.47"
android:ellipsize="end"
android:singleLine="true"
android:text=" Cochin"
android:textColor="@color/white"
android:textSize="@dimen/label_text_size_large" />
</LinearLayout>
<TextView
android:id="@+id/toolbar_sub_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="2 Seat(s)"
android:textColor="@color/lite_gray"
android:textSize="@dimen/label_text_size_normal" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.13">
<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:scaleType="fitCenter"
android:src="@drawable/filter" />
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.Toolbar>
InformationsquelleAutor Lavekush Agrawal | 2016-01-11
Du musst angemeldet sein, um einen Kommentar abzugeben.
da Sie über
CoordinatorLayout
Sie können eine benutzerdefinierteBehaviour
das erreichen können, was Sie anzubieten Folgen Beispiel:create
eine Klasse, dieextends CoordinatorLayout.Behavior<View>
Folgen Beispiel:nun für diesen
behaviour
fügen Sie diese zu Ihrem layoutInformationsquelleAutor k0sh
Diese wie ich es gemacht habe:
Brauchen Sie HideShowScrollListener.class
Die beste Antwort in meinem Fall.
Wie wäre es mit zwei verschiedenen RecyclerView verwendet??
InformationsquelleAutor krishan
}
und xml-app:layout_behavior wie..
InformationsquelleAutor Sambhaji Karad
bauen.gradle Abhängigkeit
drive.google.com/open?id=0BzBKpZ4nzNzUVi0xeU1UMjZHeFE ---- Ganze
InformationsquelleAutor Keshav Gera
@k0sh gab eine feine Lösung. Ich möchte zu aktualisieren, um eine gleichmäßige animation
während ein-und ausblenden des Layouts. Ersetzen komplette code innerhalb
onNestedPreScroll() mit dem folgenden code:
InformationsquelleAutor Prashant
Sichtbarkeit und Verstecken mit Animation in Ihrem Fragment:
HideShowScrollListener.java
InformationsquelleAutor Naveen Kumar M
@k0sh ist QuickReturnFloaterBehavior funktioniert, aber manchmal höre nicht auf die leichte Schriftrollen.
Ich bin mit Inhalt in
NestedScrollView
mit einemLinearLayout
als bottom bar & nicht die recycler anzeigen. also, ich kann nicht mit anderen vorgeschlagenen Antworten.Diejenigen, die mit der gleichen situation können die
BottomNavigationBehavior
von diesem posten Bottom Navigation Verhalten. es funktioniert perfekt & nützlich.source-code für BottomNavigationBehavior - https://gist.github.com/NikolaDespotoski/1d6fef4949eb9be05a46#file-bottomnavigationbehavior-java
Ausschnitt aus
BottomNavigationBehavior
InformationsquelleAutor Vignesh Sundar