2012-05-03 7 views
0

私は頭痛を与える多くのAndroidのバグを発見しました。マニフェストにonConfigurationChangedを使ったSlidingDrawerの回転

活動:

<activity 
     android:name=".ActivityTest" 
     android:configChanges="orientation" 
     android:label="@string/app_name" /> 

レイアウト:

<TextView 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="TEST" /> 

<SlidingDrawer 
    android:id="@+id/drawer" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:content="@+id/content" 
    android:handle="@+id/handle" 
    android:orientation="vertical" > 

    <ImageView 
     android:id="@id/handle" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:src="@drawable/ic_launcher" /> 

    <LinearLayout 
     android:id="@id/content" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:orientation="vertical" > 

     <Button 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:text="Big Big Button" /> 
    </LinearLayout> 
</SlidingDrawer> 

今..引き出しの取っ手をつかみ、そして真ん中に移動し、維持デバイスを回転させながら指を...

引き出しの寸法はすべてねじ込み...完全に開くまで。

Drawer in portrait closed Drawer half opened in portrait Drawer after rotation to landscape not resized (with finger still pressing)

誰かがそれを修正する方法のいずれかのideiaを持っていますか?私はSlidingDrawerの開かれたコードを見て、開いたときになぜ大丈夫になるのかを調べようとしています。しかし、まだ運がありません。自分で回転を処理していない

は、私はオプトインして今喜んオプションではありません...

答えて

0

[OK]を、いくつかのトリックでそれを修正するために管理...タッチイベントは時々...半分開いた引き出しを回転させた後のビューに取得しない

まず、私はその後、引き出しや拡張:追加しますいくつかのメソッドにいくつかのコード:

@Override 
protected void onLayout(boolean changed, int l, int t, int r, int b) 
{ 
    if (mTracking && !rotationStopTracking) 
    { 
     return; 
    } 
    else if (rotationStopTracking) 
    { 
     rotationStopTracking = false; 
     if (isMoving()) 
     { 
      animateOpen(); 
      close(); 
     }else{ 
      animateOpen(); 
     } 
    } 

    ... 

    } 


//Called from Activity onConfigurationChanged 
public void enableRotationResize() 
{ 
    if (mTracking) 
    { 
     mTracking = false; 
     rotationStopTracking = true; 
    } 
} 
0

私はスライド式引き出しで働いたことがありませんので、私はちょうどスローするつもりですアイデアはここにあり、おそらく壁に張り付いています。

onconfigurationが呼び出されると、screnの幅を取得して、スライド引き出しのlayout_widthをその値に設定するとどうなりますか? は、画面の半分を停止して画面を回転させたときのように、回転(回転後)の幅が回転前の幅と同じように見えます。たぶん、明示的に幅を設定すると、適切に拡張されます。

+0

そこには、それを行った。 – neteinstein

関連する問題