Android中的三星Galaxy s3中的动画效果不佳?

时间:2013-02-04 09:42:02

标签: android animation

我通过参考以下链接制作动画效果。 http://www.edumobile.org/android/android-development/custom-popup-window-example/comment-page-1/#comment-1649

代码:

     public class TutorialActivity extends Activity implements OnClickListener {

    private static String TAG = TutorialActivity.class.getSimpleName();
    private static final String NULL_STRING = "null";
    private Button mInfoBtn;
    private Animation animShow, animHide;
    private AlertDialog mErrorAlertDialog;
    private boolean isLogOff = false;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.tutorial);
        mInfoBtn = (Button) findViewById(R.id.btn_info);
        mInfoBtn.setOnClickListener(this);      

    }

    @Override
    public void onClick(View v) {

        initPopup();

    }

    /**
     * Used to show the Logoff Popup menu
     */

    private void initPopup() {

        Intent intent = getIntent();

        final PopupPanel popup = (PopupPanel) findViewById(R.id.popup_window);
        popup.setVisibility(View.VISIBLE);

        animShow = AnimationUtils.loadAnimation(this, R.anim.popup_show);
        animHide = AnimationUtils.loadAnimation(this, R.anim.popup_hide);
        popup.startAnimation(animShow);
        final Button closeButton = (Button) findViewById(R.id.btnClose);
        closeButton.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {

                popup.startAnimation(animHide);
                popup.setVisibility(View.GONE);

            }
        });

        final Button cancelAppointmet = (Button) findViewById(R.id.btnCancel);
        final Button logoff = (Button) findViewById(R.id.btnLogoff);

        logoff.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {

                popup.startAnimation(animHide);
                popup.setVisibility(View.GONE);

            }
        });
        cancelAppointmet.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                popup.startAnimation(animHide);
                popup.setVisibility(View.GONE);

            }
        });


    }



}

PopupPanel.java

     public class PopupPanel extends LinearLayout {
    private Paint innerPaint, borderPaint;

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

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

    private void init() {
        innerPaint = new Paint();
        innerPaint.setARGB(225, 0, 0, 0);
        innerPaint.setAntiAlias(true);

        borderPaint = new Paint();
        borderPaint.setARGB(255, 0, 0, 0);
        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
    protected void dispatchDraw(Canvas canvas) {

        RectF drawRect = new RectF();
        drawRect.set(0, 0, getMeasuredWidth(), getMeasuredHeight());

        canvas.drawRoundRect(drawRect, 5, 5, innerPaint);
        canvas.drawRoundRect(drawRect, 5, 5, borderPaint);

        super.dispatchDraw(canvas);
    }

}

tutorial.xml

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <RelativeLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" >

        <RelativeLayout
            android:id="@+id/heading"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:background="@drawable/header_bg_short" >

            <Button
                android:id="@+id/btn_info"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentLeft="true"
                android:layout_centerVertical="true"
                android:layout_marginLeft="10px"
                android:background="@drawable/btn_info" >
            </Button>

            <ImageView
                android:id="@+id/iveMailMinder"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                android:src="@drawable/header_text" />
        </RelativeLayout>

        <ImageView
            android:id="@+id/tutorilaimage"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_below="@id/heading"
            android:scaleType="fitXY"
            android:src="@drawable/tutorial_android3" />
    </RelativeLayout>

    <com.xxx.com.PopupPanel
        android:id="@+id/popup_window"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom"
        android:gravity="left"
        android:orientation="vertical"
        android:visibility="gone" >

        <Button
            android:id="@+id/btnClose"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="15dp"
            android:layout_marginRight="15dp"
            android:layout_marginTop="10dp"
            android:enabled="false"
            android:text="@string/btn_close_name"
            android:textSize="16sp"
            android:textStyle="bold" />

        <Button
            android:id="@+id/btnLogoff"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="15dp"
            android:layout_marginRight="15dp"
            android:layout_marginTop="5dp"
            android:enabled="false"
            android:text="@string/btn_logoff_name"
            android:textSize="16sp"
            android:textStyle="bold" />

        <Button
            android:id="@+id/btnCancel"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="5dp"
            android:layout_marginLeft="15dp"
            android:layout_marginRight="15dp"
            android:layout_marginTop="10dp"
            android:text="@string/btn_cancel_name"
            android:textSize="16sp"
            android:textStyle="bold" />
    </com.xxx.com.PopupPanel>

</FrameLayout>

.Code正在除三星Galaxy S3 之外的所有设备上工作。

当我点击“信息”按钮时,我正在显示动画。

观察到在S3中,当我长按“信息”按钮时,动画即将到来。正常的点击事件动画不会到来。

3 个答案:

答案 0 :(得分:0)

我遇到了同样的问题,但我通过将清单中的targetSDk设置为14来修复它

答案 1 :(得分:0)

如果我将tragetVersion设置为14,那么在高级版本(如jelly Bean)中会观察到一些UI更改。我的意图不会影响用户界面,我需要解决问题。

答案 2 :(得分:0)

当我启用“Fource GPU Rendering”时,动画在S3中工作。但我需要查看reaseon