I have this custom "bottom action bar" here: https://youtu.be/TPi5jtcs2wE, that appears and disappears with certain types of webpages (e.g. article/not article). I set up the outermost LinearLayout
with animateLayoutTransition
and made a different LayoutTransition
object, but I want the bar to disappear at the same time as the webview adjusts its height. To be clear, the bar (relativeLayout) is being set to View.GONE
and the webView should expand to match parent (due to layout_weight) since the bar is gone, but it's not doing both at the same time. I tried changing LayoutTransition.setDuration()
and .setStartDelay()
.
The articleActivity xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:id="@+id/container_article"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="app.morningsignout.com.morningsignoff.ArticleActivity"
tools:ignore="MergeRootFrame"
android:background="@android:color/white"
android:animateLayoutChanges="true">
<app.com.morningsignout.morningsignout.CustomWebView
android:layout_width="match_parent"
android:layout_height="0dp"
android:id="@+id/webView_article"
android:layout_gravity="center"
android:layout_weight="9" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="?android:attr/actionBarSize"
android:layout_weight="0"
The configuration of the LayoutTransition:
LinearLayout container = (LinearLayout) findViewById(R.id.container_article);
LayoutTransition customTransition = new LayoutTransition();
customTransition.enableTransitionType(LayoutTransition.CHANGING);
customTransition.disableTransitionType(LayoutTransition.CHANGE_APPEARING);
customTransition.disableTransitionType(LayoutTransition.CHANGE_DISAPPEARING);
customTransition.setAnimator(LayoutTransition.APPEARING, showArticleBar);
customTransition.setAnimator(LayoutTransition.DISAPPEARING, hideArticleBar);
customTransition.setStartDelay(LayoutTransition.APPEARING, 0);
customTransition.setStartDelay(LayoutTransition.DISAPPEARING, 0);
customTransition.setStartDelay(LayoutTransition.CHANGING, 0);
customTransition.setDuration(LayoutTransition.APPEARING, showArticleBar.getDuration());
customTransition.setDuration(LayoutTransition.DISAPPEARING, hideArticleBar.getDuration());
customTransition.setDuration(LayoutTransition.APPEARING, showArticleBar.getDuration());
container.setLayoutTransition(customTransition);
hide_action_bar.xml:
<?xml version="1.0" encoding="utf-8"?>
<objectAnimator xmlns:android="http://schemas.android.com/apk/res/android"
android:propertyName="translationY"
android:duration="300"
android:valueFrom="0"
android:valueTo="?android:attr/actionBarSize"/>
show_action_bar.xml:
<?xml version="1.0" encoding="utf-8"?>
<objectAnimator xmlns:android="http://schemas.android.com/apk/res/android"
android:propertyName="translationY"
android:duration="300"
android:valueFrom="?android:attr/actionBarSize"
android:valueTo="0"/>
I though the LayoutTransition.CHANGING
animation would make it work, but no. How do I get the webView's height change and the removal of the bar to occur at the same time? Despite setting durations and start delays to line up, it's not working. I think the issue is that CHANGING
has to happen after View.GONE
because of needing to know height after the view is gone. Either that or this is not a CHANGING
animation.