I want to hide ActionBar when scrolling on my RecyclerView. To do that I'm using the quick return pattern.
Here is my styles.xml
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="android:windowActionBarOverlay">true</item>
<!-- Support library compatibility -->
<item name="windowActionBarOverlay">true</item>
</style>
Here is my layout
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="?attr/actionBarSize">
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swipe_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include layout="@layout/recyclerview"/>
</android.support.v4.widget.SwipeRefreshLayout>
<include layout="@layout/empty_layout"/>
<fragment
android:id="@+id/adFragment"
android:name="com.myapp.fragment.AdFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true" />
</RelativeLayout>
Here is my code to show/hide actionbar
@Override
public void onUpOrCancelMotionEvent(ScrollState scrollState) {
ActionBar ab = ((ActionBarActivity)getActivity()).getSupportActionBar();
boolean tabletSize = getResources().getBoolean(R.bool.isTablet);
if (!tabletSize) {
if (scrollState == ScrollState.UP) {
if (ab.isShowing()) {
ab.hide();
}
} else if (scrollState == ScrollState.DOWN) {
if (!ab.isShowing()) {
ab.show();
}
}
}
}
I'm using ?attr/actionBarSize
to avoid flickering.
But when ActionBar is hiding I'm still having the paddingTop.
How can I remove this paddingTop on the right screen when ActionBar is hidden ?