2013-09-16 5 views
0

이 질문에서 대답하는 @lnamdar (Drawer layout with fixed menu item)와 동일한 작업을 수행하려고합니다. 나는 그들의 해결책에 대한 더 나은 설명을 얻으려고 노력하고있다.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" 
android:background="@android:color/black"> 

<!-- The main content view --> 
<FrameLayout 
    android:id="@+id/content_frame" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" /> 

<RelativeLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_gravity="start" 
    android:background="@android:color/transparent"> 
    <TextView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:background="@color/black" 
     android:text="This is the footer text"/> 

</RelativeLayout> 

<!-- The navigation drawer --> 
<ListView 
    android:id="@+id/left_drawer" 
    android:layout_width="300dp" 
    android:layout_height="match_parent" 
    android:layout_gravity="start" 
    android:choiceMode="singleChoice" 
    android:background="@android:color/black"/> 

을하지만이 목록보기는 표시하지 않도록 일으키는 내가 개방 전환 할 때/나는 바닥 글입니다 볼 수있는 유일한 일을 닫습니다

나는이 노력하고있어. ListView와 바닥 글 textView를 RelativeLayout에 넣으려고했으나 서랍 레이아웃 클래스에 사용 된 Layout Params에서 ClassCastException과 충돌합니다.

도움 주셔서 감사합니다.

답변

0

RelativeLayout을 사용하여 시도한 결과 컨텐트 프레임 안에 없었으므로 예기치 않은 결과가 나타났습니다. RelativeLayout이 ListView의 부모이기 때문에 중력을 이동시키는 메뉴 항목을 가지고 있기 때문에 설명이 매우 간단합니다. 대신 중력이 같은 ListView을 사용하십시오. 여기 내가 무슨 짓을 :

<ListView 
    android:id="@+id/left_drawer" 
    android:layout_width="240dp" 
    android:layout_height="match_parent" 
    android:background="#111" 
    android:choiceMode="singleChoice" 
    android:divider="@android:color/transparent" 
    android:dividerHeight="0dp" /> 

<TextView 

     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:background="?android:attr/activatedBackgroundIndicator" 
     android:gravity="center_vertical" 
     android:id="@+id/logout_item" 
     android:minHeight="?android:attr/listPreferredItemHeightSmall" 
     android:paddingLeft="16dp" 
     android:paddingRight="16dp" 
     android:text="@string/logout" 
     android:textAppearance="?android:attr/textAppearanceListItemSmall" 
     android:textColor="#fff" /> 

</FrameLayout> 
</RelativeLayout> 

불필요한 ViewGroup을 없애기 위해 HierarchyViewer를 실행하는 것을 잊지 마십시오.

+0

Nikola에게 감사의 말을 전하고 싶습니다. 그러던 중 나는 같은 결론에 도달하고 그것을 할 수있었습니다. 정말 도움을 주셔서 감사합니다! – cperes