Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to create Toolbar text animation in android

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 1.30k
    Comment on it

    In the below example I have created Toolbar text animation function. Here In activity_main.xml layout first I have created Toolbar and added a TextView, then In MainActivity I have used ObjectAnimator class. You can see below program it will clearly describe you to create Toolbar text 3D animation in android.

    
    Step(1)-Create actvity_main.xml layout-
    <?xml version="1.0" encoding="utf-8"?>
    <android.support.design.widget.CoordinatorLayout 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="match_parent"
        android:layout_height="match_parent"
        android:fitsSystemWindows="true"
        tools:context="com.tiwari.rajshekhar.objectanimation.MainActivity">
    
        <android.support.design.widget.AppBarLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:theme="@style/AppTheme.AppBarOverlay">
    
            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                android:background="?attr/colorPrimary"
                android:textAlignment="center"
                app:popupTheme="@style/AppTheme.PopupOverlay" >
    
    
                    <TextView
                        android:id="@+id/text_view"
                        android:layout_centerInParent="true"
                        android:textAlignment="center"
                        android:textSize="36sp"
                        android:textStyle="bold"
                        android:textColor="#9600FF00"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="Rajshekhar" />
    
    
    
                </android.support.v7.widget.Toolbar>
    
        </android.support.design.widget.AppBarLayout>
    
        <include layout="@layout/content_main" />
    
    
    
    </android.support.design.widget.CoordinatorLayout>
    
    Step(2)-MainActivity-
    
    public class MainActivity extends Activity {
    
            @Override
            protected void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
                setContentView(R.layout.activity_main);
                View v = findViewById(R.id.text_view);
                ObjectAnimator animation = ObjectAnimator.ofFloat(v, "rotationY", 0.0f, 360f);
                animation.setDuration(3600);
    
                animation.setRepeatCount(ObjectAnimator.INFINITE);
    
                animation.setInterpolator(new AccelerateDecelerateInterpolator());
                animation.start();
            }
    
        }
    

     

     

     

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: