두 개의 오버레이 조각이있는 Facebook 앱과 유사한 서랍 기능을 만들고 싶습니다.오버레이 조각이 클릭 이벤트에 예기치 않게 반응합니다.
주요 레이아웃은 다음과 같습니다
<merge
xmlns:android="http://schemas.android.com/apk/res/android" >
<fragment
android:id="@+id/menu"
android:name="ch.simon.drawertest.MenuFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginRight="80dp" />
<fragment
android:id="@+id/home"
android:name="ch.simon.drawertest.HomeScreenFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</merge>
홈 조각은 서랍을 열고 왼쪽 상단 모서리에있는 버튼이 포함되어 있습니다. 개봉은 HomeScreenFragment
안에있는 TranslateAnimation으로 발생합니다.
public void open(){
translateTo(canScrollXBy());
}
public void close(){
translateTo(0);
}
private void translateTo(int x){
Log.e(TAG, "Translate from " +mTranslated +" to " +x);
TranslateAnimation anim = new TranslateAnimation(mTranslated, x, 0, 0);
anim.setDuration(500);
anim.setFillAfter(true);
mRootView.startAnimation(anim);
mTranslated = x;
}
개폐가 잘 작동하지만 나는이 예기치 않은 동작이 관찰 :
서랍이 닫히고
HomeScreenFragment
완전히MenuFragment
을 포함하더라도 때MenuFragment
여전히 이벤트를 클릭 수신합니다.서랍이 열려 있고
HomeScreenFragment
의 버튼이 화면 오른쪽 상단에있는 경우 여전히 왼쪽에있는 것처럼 클릭 이벤트가 수신됩니다. 즉, 버튼이 오른쪽에 있더라도 탭하려면 화면 왼쪽을 탭해야합니다.
멋진 서랍 라이브러리를 보았지만 그 중 일부를 좋아하지 않았습니다. 전에 이것을 체크 아웃하지 않았습니다. 감사. – SimonSays