1. Download our Official Android App: Forums for Android!

Apps Animation to canvas

Discussion in 'Android Development' started by smita, Jan 4, 2011.

  1. smita

    smita Newbie
    Thread Starter
    Rank:
    None
    Points:
    36
    Posts:
    15
    Joined:
    Dec 22, 2010

    Dec 22, 2010
    15
    1
    36
    Developer
    India
    I have created a project in which i design a transparent_panel and arrenge these on canvas i want to apply animation to pannel. can anybody help me.

    public class Pannel1 extends LinearLayout{
    public Paint innerPaint, borderPaint ;
    Canvas c;

    public Pannel1(Context context, AttributeSet attrs) {
    super(context, attrs);
    init();

    }

    public Pannel1(Context context) {
    super(context);
    init();
    }

    public void init() {
    innerPaint = new Paint();
    innerPaint.setARGB(225, 75, 75, 75); //gray
    innerPaint.setAntiAlias(true);
    borderPaint = new Paint();
    borderPaint.setARGB(255, 255, 255, 255);
    borderPaint.setAntiAlias(true);
    borderPaint.setStyle(Style.STROKE);
    borderPaint.setStrokeWidth(2);
    }

    public void setInnerPaint(Paint innerPaint) {
    this.innerPaint = innerPaint;
    }

    public void setBorderPaint(Paint borderPaint) {
    this.borderPaint = borderPaint;
    }


    @Override
    public void dispatchDraw(Canvas canvas)
    { c=canvas;

    RectF drawRect = new RectF();
    drawRect.set(0,0, getMeasuredWidth(),getMeasuredHeight());
    canvas.drawRoundRect(drawRect, 10, 10, innerPaint);
    canvas.drawRoundRect(drawRect, 10, 10, borderPaint);
    super.dispatchDraw(canvas);

    }
    public void rotet(Canvas c1)
    { c1=this.c;
    c1.translate(-10,-10);
    dispatchDraw(c1);
    }


    }
    and my xml file is
    ?xml version="1.0" encoding="utf-8"?>

    <!--<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/home_container"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"> -->

    <TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:stretchColumns="1">
    <TableRow>
    <com.android.panel.Pannel1
    android:id="@+id/transparent_panel1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:paddingTop="5px"
    android:paddingLeft="5px"
    android:paddingBottom="5px"
    android:paddingRight="5px"
    android:layout_marginTop="50px"
    android:layout_marginLeft="20px"
    android:layout_marginRight="20px" android:eek:nClick="@string/buttonHandler2" android:clickable="true" android:focusable="true">

    <Button android:text="@+id/Button01" android:id="@+id/Button01" android:layout_width="wrap_content" android:layout_height="wrap_content" ></Button>
    <Button android:text="@+id/Back" android:id="@+id/Button03" android:layout_width="wrap_content" android:layout_height="wrap_content" ></Button>

    </com.android.panel.Pannel1>

    <com.android.panel.Pannel4
    android:id="@+id/transparent_panel"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:paddingTop="5px"
    android:paddingLeft="5px"
    android:paddingBottom="5px"
    android:paddingRight="5px" android:layout_marginTop="50px" android:layout_marginRight="10px">

    <Button android:text="@+id/Button01" android:id="@+id/Button01" android:layout_width="wrap_content" android:layout_height="wrap_content" ></Button>
    <Button android:text="@+id/Button03" android:id="@+id/Button03" android:layout_width="wrap_content" android:layout_height="wrap_content" ></Button>
    </com.android.panel.Pannel4>
    </TableRow>

    <TableRow >
    <com.android.panel.Pannel2
    android:id="@+id/transparent_panel"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:paddingTop="5px"
    android:paddingLeft="5px"
    android:paddingBottom="5px"
    android:paddingRight="5px" android:focusableInTouchMode="true" android:hapticFeedbackEnabled="true"
    android:layout_marginRight="10px" android:layout_marginTop="50px" >

    <Button android:text="@+id/Button04" android:id="@+id/Button04" android:layout_width="wrap_content" android:layout_height="wrap_content" ></Button>
    <Button android:text="@+id/Button02" android:id="@+id/Button02" android:layout_width="wrap_content" android:layout_height="wrap_content" ></Button>

    </com.android.panel.Pannel2>
    <com.android.panel.Pannel5
    android:id="@+id/transparent_panel"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:paddingTop="5px"
    android:paddingLeft="5px"
    android:paddingBottom="5px"
    android:paddingRight="5px" android:layout_marginTop="50px" android:layout_marginRight="10px" >

    <Button android:text="@+id/Button01" android:id="@+id/Button01" android:layout_width="wrap_content" android:layout_height="wrap_content" ></Button>
    <Button android:text="@+id/Button03" android:id="@+id/Button03" android:layout_width="wrap_content" android:layout_height="wrap_content" ></Button>
    </com.android.panel.Pannel5>
    <com.android.panel.Pannel6
    android:id="@+id/transparent_panel"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:paddingTop="5px"
    android:paddingLeft="5px"
    android:paddingBottom="5px"
    android:paddingRight="5px" android:layout_marginTop="50px" >

    <Button android:text="@+id/Button01" android:id="@+id/Button01" android:layout_width="wrap_content" android:layout_height="wrap_content" ></Button>
    <Button android:text="@+id/Button03" android:id="@+id/Button03" android:layout_width="wrap_content" android:layout_height="wrap_content" ></Button>
    </com.android.panel.Pannel6>
    </TableRow>

    <TableRow>
    <com.android.panel.Pannel3
    android:id="@+id/transparent_panel"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:paddingTop="5px"
    android:paddingLeft="5px"
    android:paddingBottom="5px"
    android:paddingRight="5px" android:layout_marginLeft="20px" android:layout_marginRight="20px" android:layout_marginTop="50px" android:layout_marginBottom="30px">

    <Button android:text="@+id/Button02" android:id="@+id/Button02" android:layout_width="wrap_content" android:layout_height="wrap_content" ></Button>
    <Button android:text="@+id/Button05" android:id="@+id/Button05" android:layout_width="wrap_content" android:layout_height="wrap_content" ></Button>
    </com.android.panel.Pannel3>
    <com.android.panel.Pannel7

    android:id="@+id/transparent_panel"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:paddingTop="5px"
    android:paddingLeft="5px"
    android:paddingBottom="5px"
    android:paddingRight="5px" android:layout_marginRight="20px" android:layout_marginTop="50px" android:layout_marginBottom="30px">

    <Button android:text="@+id/Button01" android:id="@+id/Button01" android:layout_width="wrap_content" android:layout_height="wrap_content" ></Button>
    <Button android:text="@+id/Button03" android:id="@+id/Button03" android:layout_width="wrap_content" android:layout_height="wrap_content" ></Button>

    </com.android.panel.Pannel7>
    </TableRow>
    </TableLayout>

    <!-- </LinearLayout>

    how can i apply zoom effect to indivisual pannel.
     

    Advertisement

Share This Page

Loading...