Last active
May 23, 2018 01:29
-
-
Save seupedro/417a07bbac9c8105dc6a9e3f1e7898d5 to your computer and use it in GitHub Desktop.
Simple android:animateLayoutChanges="true" example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
xmlns:tools="http://schemas.android.com/tools" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:animateLayoutChanges="true" | |
android:layout_gravity="center" | |
android:orientation="horizontal" | |
android:id="@+id/linear" | |
android:background="@color/colorAccent" | |
tools:context=".AnimatedLinearLayout"> | |
<ImageView | |
android:layout_margin="8dp" | |
android:layout_width="48dp" | |
android:layout_height="48dp" | |
android:src="@mipmap/ic_launcher"/> | |
<TextView | |
android:layout_margin="16dp" | |
android:id="@+id/tvText" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:text="some text" | |
android:textAppearance="?android:attr/textAppearanceLarge"/> | |
</LinearLayout> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.nakamoto.fishtool; | |
import android.animation.LayoutTransition; | |
import android.app.Activity; | |
import android.os.Bundle; | |
import android.view.View; | |
import android.widget.LinearLayout; | |
import android.widget.TextView; | |
public class AnimatedLinearLayout extends Activity { | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_animated); | |
LinearLayout linear = findViewById(R.id.linear); | |
linear.getLayoutTransition().enableTransitionType(LayoutTransition.CHANGING); | |
final TextView tv = (TextView) findViewById(R.id.tvText); | |
tv.setOnClickListener(new View.OnClickListener() { | |
@Override | |
public void onClick(View v) { | |
if (tv.getText().toString() == "some text"){ | |
tv.setText("some large text"); | |
} else { | |
tv.setText("some text"); | |
} | |
} | |
}); | |
} | |
} |
Author
seupedro
commented
May 23, 2018
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment