Android layoutanimation Use

Source: Internet
Author: User

I. Overview

Let's look at the use of layoutanimation today.

Two. Implement

Create a new animation file

<layoutAnimation xmlns:android="http://schemas.android.com/apk/res/android"    android:delay="30%"    android:animationOrder="random"    android:animation="@anim/slide_right"    />
<set xmlns:android="http://schemas.android.com/apk/res/android"    android:interpolator="@android:anim/linear_interpolator">    <translate android:fromXDelta="100%p"        android:toXDelta="0"        android:duration="900"        /></set>

Then we use the in the ListView of the layout file

<linearlayout xmlns:android="Http://schemas.android.com/apk/res/android"xmlns:tools="Http://schemas.android.com/tools"Android:layout_width="Match_parent"android:orientation="Vertical"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"> <listview android:id="@+Id/listview"Android:layout_width="Match_parent"android:layoutanimation="@anim/list_anim_layout"android:layout_height="Match_parent"android:animatelayoutchanges="true"android:scrollbars="None"> </listview></Linearlayout>

Finally, give the Java code

 Public  class mainactivity extends Activity {    PrivateListView ListView;PrivateList data =NewArrayList (); @Overrideprotected voidOnCreate (Bundle savedinstancestate) {Super. OnCreate (Savedinstancestate);        Setcontentview (R.layout.activity_main); ListView = (ListView) Findviewbyid (R.id.listview); for(inti =0;i< -; i++) {Data.add ("Yang Mi"+i); } listview.setadapter (NewMyadapter ( This, R.layout.item1,r.id.text,data)); } class myadapter extends arrayadapter<String>{         PublicMyadapter (Context context,intResourceintTextviewresourceid, list<string> objects) {Super(Context, resource, Textviewresourceid, objects); }    }}

Android layoutanimation Use

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.