2013-02-04 66 views
1

我通過引用follwing鏈接製作動畫效果。 http://www.edumobile.org/android/android-development/custom-popup-window-example/comment-page-1/#comment-1649動畫是不是在Android的三星Galaxy S3中工作?

代碼:

 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> 

。代碼工作中的所有設備,除了三星Galaxy S3

我在點擊「信息」按鈕時顯示動畫。

觀察到,在S3中,當我長時間點擊「信息」按鈕,動畫即將到來。與正常的點擊事件動畫不會來。

+0

你在測試手機關掉動畫?設置 - >開發人員選項 - >過渡動畫比例/窗口動畫比例設置爲關? – Calvin

+0

No..it設置爲1x – user2020680

+0

我面臨S3更新到4.2的相同問題,您是否找到任何解決方案?還有一件事,我添加了動畫偵聽器,並注意到只有OnAnimationStart被稱爲不OnAnimationStop .. –

回答

0

我面臨同樣的問題,但我固定它通過在清單設定targetSDk至14

+0

但是,如果我將清單中的targetSDk應用到14,那麼UI更改正在以Higer版本(ex :像4.2)。所以這不適合我。 – user2020680

0

如果我把tragetVersion爲14,則有在更高的版本觀察(象果凍Bean)的一些用戶界面的變化。我的意圖是不影響用戶界面,我需要解決這個問題。

0

當我啓用「Fource GPU渲染」,然後動畫在S3.but工作,我需要在reaseon看

相關問題