Skip to main content

Posts

Showing posts with the label animation

Zoom Animation between Activities in Android

Create an activity and call that activity from the main activity as shown below. MainActivity .class import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; public class MainActivity extends Activity { Button Zoombut; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Zoombut = (Button) findViewById(R.id.button1); Zoombut.setOnClickListener(new OnClickListener() { public void onClick(View arg0) { // TODO Auto-generated method stub Intent i = new Intent(MainActivity.this, success.class); startActivity(i); overridePendingTransition(R.anim.zoom_enter, R.anim.zoom_exit); }}); }} Create a folder in resource and name it as "anim" an create two xmls with the following animation code. Copy and paste the code from below: zoom_...

Delete A row in ListView with Animation

Listview is simply a group of view that displays a list of scrolling items. "Adapters" are used to insert list items to the list.By default we are able to provide only text as list items.In order to delete a row from listview, copy or download this javacode and try yourself. Also see here : Android – Bullets in ListView ListView in Alphabetic Order in ANDROID Single Selection ListView in android Simple ListView in Android java file : public class SimpleListViewActivity extends Activity { private ListView mainListView; private ArrayAdapter<String> listAdapter; ArrayList<String> all_rowtext = new ArrayList<String>() ; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); // Find the ListView resource. mainListView = (ListView) findViewById(R.id.mainListView); all_rowtext.add("Angel"); all_rowtext.add("Mark"); all_rowtext.add("Coding...

View Flipper with Animationin ANDROID

Suppose you have to show an item for few minutes and then flips to next one we can use viewflipper . ViewFlipper inherits from frame layout, so it displays a single view at a time. in java class: ViewFlipper vflip; vflip=(ViewFlipper) findViewById(R.id.viewFlipper1); //when a view is displayed vflip.setInAnimation(this,android.R.anim.fade_in); //when a view disappears vflip.setOutAnimation(this, android.R.anim.fade_out); vflip.setFlipInterval(500); vflip.startFlipping();//starts flippin // vflip.stopFlipping();//stops flipping in 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" > <ViewFlipper android:id="@+id/viewFlipper1" android:layout_width="wrap_content" android:l...

Android – Bullets in ListView

main.xml : <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" android:padding="10dp"> <ListView android:id="@+id/listView" android:layout_width="fill_parent" android:layout_height="wrap_content" android:listSelector="@android:color/transparent" android:divider="@null"/> </LinearLayout> create a bullet.xml in drawable folder: <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval"> <size android:height="6dp" android:width="6dp"/> ...

Blinking TextView - Two Methods

METHOD 1 private void blink(){ final Handler handler = new Handler(); new Thread(new Runnable() { public void run() { int timeToBlink = 600; //in milissegunds try { Thread.sleep(timeToBlink); }catch (Exception e) { }handler.post(new Runnable() { public void run() { TextView txt = (TextView)findViewById(R.id.usage); if(txt.getVisibility() == View.VISIBLE) { txt.setVisibility(View.INVISIBLE); }else { txt.setVisibility(View.VISIBLE); } blink(); } }); } }).start(); } METHOD 2 T...

Frame by Frame Animation in Android

Call a new xml file which includes the frames that are to be loaded: < ?xml version="1.0" encoding="utf-8"?> < animation-list android:oneshot="false" xmlns:android="http://schemas.android.com/apk/res/android"> < item android:drawable="@drawable/frame_above95_1" android:duration="30"/> < item android:drawable="@drawable/frame_above95_2" android:duration="30"/> < item android:drawable="@drawable/frame_above95_3" android:duration="30"/> < item android:drawable="@drawable/frame_above95_4" android:duration="30"/> < item android:drawable="@drawable/frame_above95_5" android:duration="30"/> < item android:drawable="@drawable/frame_above95_6" android:duration="30"/> < item android:drawable="@drawable/frame_above95_7" android:duration="...