2014-12-23 6 views
0

내 응용 프로그램에서 DrawerLayout을 구현하기 시작했으며 버튼의 선택기가 매우 느리게 응답하는 것으로 나타났습니다. DrawerLayout을 LinearLayout으로 변경하면 지연이 사라집니다. 이것이이 지체 또는 다른 것을 초래하는 DrawerLayout에서 발생하는 여분의 터치 처리로 인해 발생하는지 확실하지 않습니다. 이 지연을 줄이기 위해 제가 할 수있는 일이 있습니까? 있는 LinearLayout은 그래서 지연을 생성하는 것처럼DrawerLayout 느린 선택기 발생

<android.support.v4.widget.DrawerLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/drawer_layout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <Button 
     android:id="@+id/my_button" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:background="@drawable/button_background" 
     android:text="" /> 

</android.support.v4.widget.DrawerLayout> 

<selector xmlns:android="http://schemas.android.com/apk/res/android"> 
    <item android:state_pressed="true"> 
     <shape> 
      <solid android:color="#000080"/> 
     </shape> 
    </item> 
    <item> 
     <shape> 
      <solid android:color="#0000ff"/> 
     </shape> 
    </item> 
</selector> 

답변

0

DrawerLayout는 shouldDelayChildPressedState() 오버라이드 (override)하지 않습니다.

public class MyDrawerLayout extends DrawerLayout { 

    public MyDrawerLayout (Context context) { 
     super(context); 
    } 

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

    public MyDrawerLayout (Context context, AttributeSet attrs, int defStyle) { 
     super(context, attrs, defStyle); 
    } 

    @Override 
    public boolean shouldDelayChildPressedState() { 
     // prevents touch delay 
     return false; 
    } 
} 

내가 알 수있는 유일한 부작용은 서랍을 꺼내는 전에보기를 선택합니다 슬쩍 제스처은 다음과 같은 레이아웃 클래스를 만들 수 있었다.