Próbuję ukryć lub pokazać pasek narzędzi, gdy użytkownik przewija listę. Aby to zrobić, używam tłumaczenia, ale zamiast mojego paska akcji pojawia się puste miejsce. Jeśli używam setVisibility (View.GONE), puste miejsce pojawi się podczas animacji i ukrywać, kiedy to zrobić, który jest brzydki ..Pasek narzędzi Android pokaż/ukryj pustą przestrzeń
Here is a short video of my issue
A oto jak to zrobić mój animacji (z Google I/o app):
public void showToolbar(boolean show){
if (show) {
toolbar.animate()
.translationY(0)
.alpha(1)
.setDuration(HEADER_HIDE_ANIM_DURATION)
.setInterpolator(new DecelerateInterpolator());
} else {
toolbar.animate()
.translationY(-toolbar.getBottom())
.alpha(0)
.setDuration(HEADER_HIDE_ANIM_DURATION)
.setInterpolator(new DecelerateInterpolator());
}
}
I tu jest mój układ:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/mainContent">
<include layout="@layout/toolbar"
android:id="@+id/my_toolbar" />
<fragment
android:name="com.ar.oe.fragments.SectionsFragment"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="?attr/actionBarSize"/>
</RelativeLayout>
A mój Pasek
<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/my_toolbar"
android:layout_height="?attr/actionBarSize"
android:layout_width="match_parent"
android:minHeight="?attr/actionBarSize"
android:background="?attr/colorPrimary"
/>
Czy udało Ci się to naprawić? – chip