transition - TransitionManager scene animation behavior with root layout -


i'm testing out android kit kat transition feature. when transition happens, margins of root layout getting padded. find behavior strange.

the source

public class mainactivity extends actionbaractivity {      button btn;     textview txt;      @targetapi(build.version_codes.kitkat)     @override     protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.activity_main);          txt = (textview)findviewbyid(r.id.text);         btn = (button)findviewbyid(r.id.btn);          btn.setonclicklistener(new view.onclicklistener() {             @override             public void onclick(view view) {                 viewgroup root = (viewgroup)findviewbyid(r.id.root);                 scene scene = scene.getsceneforlayout(root, r.layout.activity_main2, mainactivity.this);                 transitionmanager.go(scene);             }         });      } ... } 

activity_main.xml

<relativelayout xmlns:android="http://schemas.android.com/apk/res/android"     xmlns:tools="http://schemas.android.com/tools"     android:layout_width="match_parent"     android:layout_height="match_parent"     android:paddingleft="@dimen/activity_horizontal_margin"     android:paddingright="@dimen/activity_horizontal_margin"     android:paddingtop="@dimen/activity_vertical_margin"     android:paddingbottom="@dimen/activity_vertical_margin"     android:id="@+id/root"     tools:context="com.sebouh00.test.scenes.mainactivity">          <button android:id="@+id/btn"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:text="click me"             android:layout_marginbottom="12dp"/>          <textview             android:id="@+id/text"             android:layout_below="@id/btn"             android:text="@string/hello_world"             android:layout_width="match_parent"             android:layout_height="match_parent"             android:textsize="18dp"/>  </relativelayout> 

activity_main2.xml

<relativelayout xmlns:android="http://schemas.android.com/apk/res/android"     xmlns:tools="http://schemas.android.com/tools"     android:layout_width="match_parent"     android:layout_height="match_parent"     android:paddingleft="@dimen/activity_horizontal_margin"     android:paddingright="@dimen/activity_horizontal_margin"     android:paddingtop="@dimen/activity_vertical_margin"     android:paddingbottom="@dimen/activity_vertical_margin"     android:id="@+id/root"     tools:context="com.sebouh00.test.scenes.mainactivity">          <button android:id="@+id/btn"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:text="click me"             android:layout_marginbottom="12dp"/>          <imageview             android:layout_width="match_parent"             android:layout_height="wrap_content"             android:layout_below="@id/btn"             android:id="@+id/img"             android:src="@drawable/flag"             android:layout_marginbottom="12dp"/>          <textview             android:id="@+id/text"             android:layout_below="@id/img"             android:text="@string/hello_world"             android:layout_width="match_parent"             android:layout_height="match_parent"             android:textsize="18dp"/> </relativelayout> 

results in this unless remove paddings activity_main2.xml

any ideas why?

it's because view produced inflating activity_main2 gets inserted scene's root, i.e. r.id.root relativelayout, padding r.id.root still applied.


Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -