Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
81 views2 pages

"1.0" "Utf-8" Linearlayout

This document contains an XML layout file defining a vertical LinearLayout containing 4 Button views with unique IDs and text. It also contains a Java class that gets references to these Button views, defines TranslateAnimation objects for left and right movement, and applies the animations to move the Buttons left and right over 2 seconds, repeating once.

Uploaded by

Ajaypal Yadav
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
81 views2 pages

"1.0" "Utf-8" Linearlayout

This document contains an XML layout file defining a vertical LinearLayout containing 4 Button views with unique IDs and text. It also contains a Java class that gets references to these Button views, defines TranslateAnimation objects for left and right movement, and applies the animations to move the Buttons left and right over 2 seconds, repeating once.

Uploaded by

Ajaypal Yadav
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

<?xml version="1.0" encoding="utf-8"?

>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<Button
android:id="@+id/btn1"
android:text="Button 1"
android:layout_width="fill_parent"
android:layout_height="45dip"
android:layout_marginTop="10dip"
/>

<Button
android:id="@+id/btn2"
android:text="Button 2"
android:layout_width="fill_parent"
android:layout_height="45dip"
android:layout_marginTop="10dip" />

<Button
android:id="@+id/btn3"
android:text="Button 3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dip"
/>

<Button
android:id="@+id/btn4"
android:text="Button 4"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dip"
/>
</LinearLayout>

import android.app.Activity;
import android.os.Bundle;
import android.view.animation.Animation;
import android.view.animation.TranslateAnimation;
import android.widget.Button;
public class LayoutMargingActivity extends Activity
{
Button b1, b2, b3, b4;

TranslateAnimation left, right;


public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

left = new TranslateAnimation(-480, 10, 0, 10);


right= new TranslateAnimation( 480, 10, 0, 10);

left.setDuration(2000);
right.setDuration(2000);

left.setRepeatCount( 1 );
right.setRepeatCount( 1 );

b1 =(Button)findViewById( R.id.btn1);
b2 =(Button)findViewById( R.id.btn2);
b3 =(Button)findViewById( R.id.btn3);
b4 =(Button)findViewById( R.id.btn4);

b1.startAnimation(left);
b2.startAnimation(right);
b3.startAnimation(left);
b4.startAnimation(right);
}
}

You might also like