2012-05-03 2 views
9

アクションビューでActionBarのMenuItemをアニメーション化しようとしました(ActionBarHelper for Honeycomb)。私はアニメーションを停止し、デフォルトのMenuItemの状態を経由してに戻したいときはAndroid:setActionView(null)は、ActionViewでMenuItemの表示と幅の問題を解決しません。

  1. 私はアクションのビューを表示すると、項目の幅がMenuItemに比べて小さい(スクリーンショットの一部1と2を参照)
  2. :しかし、私は2つの悩みを持っていますsetActionView(ヌル)、私のアクションビューはまだ私のMenuItem(スクリーンショットの一部3)

Different steps of MenuItem (Screenshots)

ActionViewレイアウト(R.layout.menu_item_refresh)内に表示されている。

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:gravity="center"> 

    <ImageView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:src="@drawable/ic_menu_refresh" /> 

</LinearLayout> 

onOptionsItemSelectedメソッドのコードは次のとおりです。私はあなたのコードの権利をundestood場合負荷が完了し

@Override 
public boolean onOptionsItemSelected(MenuItem item) { 
    switch(item.getItemId()){    
     default: 
      return super.onOptionsItemSelected(item); 

     case R.id.Menu_Feed_Refresh: 
      mAnimatedItem = item; 
      item.setActionView(R.layout.menu_item_refresh); 
      item.startAnimation(mAnimation); 

      load(); 
      return true; 
    } 
} 

、私はあなたがのMenuItemにアニメーションを適用し、

+1

これを解決できましたか? – user427969

答えて

0

ハンドラmAnimatedItem.setActionView(null)を呼び出します。あなたはActionViewをsetActionView(null)で削除しますが、menuItemはアニメーション化されます。

あなたはActionViewから画像を取得し、それにアニメーションを適用する必要があります:あなたが停止する

@Override 
public boolean onOptionsItemSelected(MenuItem item) { 
switch(item.getItemId()){    
    default: 
     return super.onOptionsItemSelected(item); 

    case R.id.Menu_Feed_Refresh: 
     mAnimatedItem = item; 
     item.setActionView(R.layout.menu_item_refresh); 
     ImageView iv = (ImageView) item.getActionView().findViewById(R.id.refresh_image_id); 
     iv.startAnimation(mAnimation); 
     load(); 
     return true; 
    } 
} 
0

コールmAnimation.clearAnimation()

関連する問題