ObjectAnimator example to rotate view

ObjectAnimator example to rotate view

ObjectAnimator example to rotate view - Hallo sahabat Teknologi Terbaru, Pada Artikel yang anda baca kali ini dengan judul ObjectAnimator example to rotate view, kami telah mempersiapkan artikel ini dengan baik untuk anda baca dan ambil informasi didalamnya. mudah-mudahan isi postingan yang kami tulis ini dapat anda pahami. baiklah, selamat membaca.

Judul : ObjectAnimator example to rotate view
link : ObjectAnimator example to rotate view

Baca juga


ObjectAnimator example to rotate view


package com.example.androidflipview;

import android.support.v7.app.ActionBarActivity;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.animation.ObjectAnimator;
import android.os.Bundle;

public class MainActivity extends ActionBarActivity {

LinearLayout mainLayout;
TextView textTitle;
Button buttonFlip;
ImageView image;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mainLayout = (LinearLayout)findViewById(R.id.mainlayout);
mainLayout.setOnClickListener(MyOnClickListener);
textTitle = (TextView)findViewById(R.id.title);
textTitle.setOnClickListener(MyOnClickListener);
buttonFlip = (Button)findViewById(R.id.buttonflip);
buttonFlip.setOnClickListener(MyOnClickListener);
image = (ImageView)findViewById(R.id.image);
image.setOnClickListener(MyOnClickListener);

}

OnClickListener MyOnClickListener = new OnClickListener(){

@Override
public void onClick(View v) {
rotateit(v);
}

};

private void rotateit(final View viewToFlip) {
ObjectAnimator rot = ObjectAnimator.ofFloat(viewToFlip, "rotation", 0f, 360f);
rot.setDuration(3000);
rot.start();

}

}

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/mainlayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:orientation="vertical"
tools:context="com.example.androidflipview.MainActivity" >

<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="android-coding.blogspot.com"
android:textSize="28dp"
android:textStyle="bold" />

<Button
android:id="@+id/buttonflip"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Rotate" />

<ImageView
android:id="@+id/image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher" />

</LinearLayout>


Demikianlah Artikel ObjectAnimator example to rotate view

Sekianlah artikel ObjectAnimator example to rotate view kali ini, mudah-mudahan bisa memberi manfaat untuk anda semua. baiklah, sampai jumpa di postingan artikel lainnya.


0 Response to "ObjectAnimator example to rotate view"

Post a Comment