2015-07-27 8 views
12

दो सूचियों वाले नेविगेशन ड्रॉवर में एक पाद लेख जोड़ने का प्रयास कर रहा है। मैं यह सही नहीं कर रहा हूँ, मैं समझ गया कि कुछ भी है कि मैं नेविगेशन ड्रॉर के चाहतेनेविगेशन ड्रॉवर पर नीचे लेआउट एंड्रॉइड

<LinearLayout 
      android:id="@+id/left_drawer_layout" 

मैं एक नीचे लेआउट कि ListView पुस्तक पर निर्भर नहीं करता जोड़ना चाहते हैं में समाहित किया जाना चाहिए। मैंने नीचे लेआउट कोड जोड़ने के विभिन्न संस्करणों की कोशिश की लेकिन कुछ भी नहीं हुआ। मुझे एक अतिरिक्त आंख चाहिए, कृपया। धन्यवाद।

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

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="fill_parent" 
     android:orientation="vertical"> 

     <include 
      android:id="@+id/toolbar" 
      layout="@layout/toolbar”/> 



     <!-- Framelayout to display Fragments --> 

     <FrameLayout 
      android:id="@+id/frame_container" 
      android:layout_width="match_parent" 
      android:layout_height="0dp" 
      android:layout_weight="1" /> 

    </LinearLayout> 


    <!-- Listview to display slider menu --> 

    <LinearLayout 
     android:id="@+id/left_drawer_layout" 
     android:layout_width="@dimen/navigation_drawer_max_width" 
     android:layout_height="match_parent" 
     android:layout_gravity="start" 
     android:orientation="vertical"> 


     <FrameLayout 
      android:layout_width="match_parent" 
      android:layout_height="48dp" 
      android:background="@color/list_background"> 

      <Button 
       android:id="@+id/refreshBtn" 
       android:layout_width="match_parent" 
       android:layout_height="48dp" 
       android:text="@string/refresh" 
       android:visibility="gone" /> 

      <EditText 
       android:id="@+id/searchMenuTxt" 
       android:layout_width="match_parent" 
       android:layout_height="48dp" 
       android:background="@color/list_background_pressed" 
       android:drawableLeft="@drawable/search_web" 
       android:drawablePadding="@dimen/activity_horizontal_margin" 
       android:drawableStart="@drawable/search_web" 
       android:focusable="false" 
       android:focusableInTouchMode="true" 
       android:hint="@string/search" 
       android:paddingLeft="8dp" 
       android:singleLine="true" 
       android:textColorHint="@android:color/darker_gray" 
       android:textSize="@dimen/text_size_14"></EditText> 

      <Button 
       android:id="@+id/clearBtn" 
       android:layout_width="24dp" 
       android:layout_height="24dp" 
       android:layout_gravity="right|center" 
       android:background="@drawable/mob_clear" 
       android:paddingRight="8dp" 
       android:visibility="invisible" /> 

     </FrameLayout> 

     <LinearLayout 
      android:id="@+id/left_drawer" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:orientation="vertical"> 

      <ListView 
       android:id="@+id/activeChatsList" 
       android:layout_width="@dimen/navigation_drawer_max_width" 
       android:layout_height="wrap_content" 
       android:layout_gravity="start" 
       android:background="@color/list_background_pressed" 
       android:choiceMode="singleChoice" 
       android:divider="@drawable/list_divider" 
       android:dividerHeight="1dp" 
       android:fadeScrollbars="false" 
       android:fastScrollEnabled="false" /> 

      <ListView 
       android:id="@+id/drawerListView" 
       android:layout_width="@dimen/navigation_drawer_max_width" 
       android:layout_height="match_parent" 
       android:layout_gravity="start" 
       android:background="@drawable/list_selector" 
       android:choiceMode="singleChoice" 
       android:divider="@drawable/list_divider" 
       android:dividerHeight="1dp" 
       android:drawSelectorOnTop="true" 
       android:fastScrollEnabled="false" 
       android:minHeight="250dp" /> 
      <LinearLayout 
       android:layout_width="fill_parent" android:layout_height="wrap_content" 
       android:layout_weight="1" 
       android:layout_alignParentBottom="true"> 

       <Button android:id="@+id/CancelButton" android:layout_width="wrap_content" 
        android:layout_height="wrap_content" android:text=“Profile" /> 
       > 

      </LinearLayout> 
     </LinearLayout> 


    </LinearLayout> 

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

शायद क्योंकि आपके drawerListView ऊंचाई –

+0

चाल – user1140656

+0

नहीं किया match_parent है आप चाहते हैं बटन दराज विजेट के तल पर ठीक करने की कोई बात नहीं कितना बड़ा listviews हैं? साथ ही, यह शायद ही कभी एक अच्छा विचार है कि दो सूची दृश्य एक दूसरे के बाद हो। – Luksprog

उत्तर

3

आप इस कोड स्निपेट से मूल विचार प्राप्त कर सकते हैं। और एंड्रॉइड में अब मेनू ड्रॉवर के लिए अंतर्निहित कार्यक्षमता है। आप जो करने की कोशिश कर रहे हैं वह पुराना दृष्टिकोण है। एक्शनबार शेरलॉक को हटा दिया गया है। तो मैं आपको AppCompat पर जाने की सलाह दूंगा। एपकोम्पेट के साथ फूटर के साथ मेनू ड्रॉवर का लेआउट रखने के लिए कोड है।

drawer_fragment।एक्सएमएल

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
xmlns:app="http://schemas.android.com/apk/res/com.focial" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:background="@android:color/transparent" > 

<RelativeLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@android:color/white" > 

    <LinearLayout 
     android:id="@+id/footer" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_gravity="bottom" 
     android:clickable="true" 
     android:background="@android:color/black" 
     android:orientation="vertical"> 

    <!-- any addition stuff you want in yoour footer layout --> 

    </LinearLayout> 

    <ListView 
     android:id="@+id/drawer_list" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_above="@id/footer" 
     android:choiceMode="singleChoice" 
     android:dividerHeight="1dp" /> 
</RelativeLayout> 

activity_home.xml

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

<FrameLayout 
    android:id="@+id/realcontent" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" /> 

<fragment 
    android:id="@+id/navigation_drawer" 
    android:name="com.focial.fragment.NavigationDrawerFragment" 
    android:layout_width="@dimen/navigation_drawer_width" 
    android:layout_height="match_parent" 
    android:layout_gravity="start" /> 

HomeActivity.java

private NavigationDrawerFragment mNavigationDrawerFragment; 
private ArrayList<DrawerItem> drawerItems; 
private DrawerLayout drawerLayout; 

protected void initUIComponents() { 
    drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); 
    mNavigationDrawerFragment = (NavigationDrawerFragment) getSupportFragmentManager().findFragmentById(R.id.navigation_drawer); 
    mNavigationDrawerFragment.setUp(R.id.navigation_drawer, drawerLayout, drawerItems); 
} 

@Override 
public void onNavigationDrawerItemSelected(int itemlabelId) { 
    FragmentManager fragmentManager = getSupportFragmentManager(); 
    fragmentManager.beginTransaction().replace(R.id.realcontent, CustomFragmentManager.newInstance(itemlabelId)).commit(); 
} 

NavigationDrawerFragment (जहां/शो दराज सक्षम करना चाहते हैं) जावा

View rootView = (RelativeLayout) inflater.inflate(R.layout.layout_fragment_drawer, container, false); 
ListView mDrawerListView = (ListView) rootView.findViewById(R.id.drawer_list); 
    LinearLayout footerView = (LinearLayout) rootView.findViewById(R.id.footer); 
0

आपका बाईं दराज लेआउट जरूरी, एक LinearLayout होने की जरूरत नहीं है यह हो सकता है कुछ की तरह:

<RelativeLayout 
    android:id="@+id/left_drawer_layout" 
    android:layout_width="@dimen/navigation_drawer_max_width" 
    android:layout_height="match_parent"> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_above="@+id/drawer_footer" 
     android:layout_gravity="start" 
     android:orientation="vertical"> 

     <!-- YOUR PREVIOUS LAYOUT --> 
    </LinearLayout> 

    <LinearLayout 
     android.id="@+id/drawer_footer" 
     android:layout_width="match_parent" 
     android:layout_alignParentBottom="true" 
     android:layout_height="100dp"> 
     <!-- YOUR FOOTER WITH layout_alignParentBottom --> 
    </LinearLayout> 
</RelativeLayout> 

उस स्थिति में आपके पाद लेख हमेशा अपनी बाईं दराज के तल पर किया जाएगा।

+0

इसके बजाय फ़्रेमलेआउट पर विचार करें और बेहतर प्रदर्शन के लिए गुरुत्वाकर्षण का उपयोग करें। सापेक्ष लयआउट महंगा है क्योंकि यह दो बार उपाय करता है। – JohanShogun

-1

आपको दराज नियंत्रण टैग के बाद फ्रेम लेआउट का उपयोग करना होगा।

फ्रेम लेआउट में सभी नियंत्रण रखें।

+0

कृपया अपने उत्तर का एक उदाहरण दें, और यह भी क्यों है कि ऐसा होना चाहिए ... –

0

आप अपने प्रोजेक्ट पर इस दराज या क्या इस परियोजना https://github.com/neokree/MaterialNavigationDrawer

परियोजना पर इस्तेमाल किया जैसे कुछ लेआउट का उपयोग कर सकते पाद लेख लेआउट के लिए addBottomSection विधि है

आप इस apk में इस परियोजना का उदाहरण देख सकते हैं: https://github.com/neokree/MaterialNavigationDrawer/blob/master/example.apk

0

क्योंकि आपके drawerListView के android:layout_height="match_parent", इसलिए यह सभी ऊंचाई को स्क्री में छोड़ दिया जाता है और स्क्रीन के नीचे लेआउट को धक्का देता है।
आप इस कोशिश कर सकते हैं:

<LinearLayout 
android:id="@+id/left_drawer" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:orientation="vertical" > 

<LinearLayout 
    android:layout_width="fill_parent" 
    android:layout_height="0dp" 
    android:layout_weight="1" 
    android:orientation="vertical" > 

    <ListView 
     android:id="@+id/activeChatsList" /> 

    <ListView 
     android:id="@+id/drawerListView" /> 
</LinearLayout> 

<Button 
    android:id="@+id/CancelButton" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="“Profile" /> 

</LinearLayout> 

कि के बगल में, मैं सुझाव है कि आप के बजाय 2 अलग सूची दृश्य के अनुकूलक में बहु viewType साथ 1 सूची दृश्य का उपयोग करना चाहिए क्योंकि अगर 1 स्क्रॉल तो 2 दिखाई नहीं देंगे या यदि दूसरा शो अप है, तो इसका मतलब है कि पहले को स्क्रॉल करने की आवश्यकता नहीं है, इसलिए यह एक सूचीदृश्य होना व्यर्थ है।
हॉप इससे मदद करता है।

0

सबसे अच्छा तरीका है पाद लेख के लिए एक और लेआउट बनाना और उस सूची को अपनी सूची पाद लेख में जोड़ें।

listView.addFooterView(R.layout.<your footer layout>); 
0

यह केवल सुझाव है। मैं इसे अपने उत्तर के रूप में जोड़ रहा हूं क्योंकि मेरे पास अन्य पदों पर टिप्पणी जोड़ने के लिए पर्याप्त प्रतिष्ठा नहीं है, क्षमा करें। मुझे लगता है कि यह पहले से ही हल हो चुका है। कृपया नीचे दिए गए लिंक को देखें How to put list items at the bottom of list view in Navigation Drawer like Foursquare

+0

क्या आप कृपया कुछ नमूना स्क्रीन जोड़ सकते हैं ताकि इससे बेहतर तरीके से देखा जा सके। –

0

आप एक्शनबैरशॉक लाइब्रेरी का उपयोग कर सकते हैं। मुझे लगता है कि यह बहुत उपयोगी है।

संबंधित मुद्दे