How to make the ListView was at the bottom of the toolbar, and not as crooked as on a picch? And another question, how to remove these strips between the ListView elements? enter image description here

Here is the xml file main activity.

<?xml version="1.0" encoding="utf-8"?> <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/drawer_layout" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true" tools:openDrawer="start"> <include layout="@layout/app_bar_main" android:layout_width="match_parent" android:layout_height="match_parent" /> <ListView android:id="@+id/list" android:layout_width="wrap_content" android:layout_height="wrap_content" android:dividerHeight="1dp" android:listSelector="@drawable/list_row_selector" /> <android.support.design.widget.NavigationView android:id="@+id/nav_view" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_gravity="start" android:fitsSystemWindows="true" app:headerLayout="@layout/nav_header_main" app:menu="@menu/activity_main_drawer" /> </android.support.v4.widget.DrawerLayout> 

Here is the code for the onCreate method in MainActivity

 protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); ActionBarDrawerToggle toggle = new ActionBarDrawerToggle( this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); drawer.addDrawerListener(toggle); toggle.syncState(); NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); navigationView.setNavigationItemSelectedListener(this); ListViewAdapter adapter = new ListViewAdapter(this); ListView lvMain = (ListView) findViewById(R.id.list); lvMain.setAdapter(adapter); } 

    1 answer 1

    1. DrawerLayout should have only two children:

      • Main content
      • Left menu

    You have three of them. So you need to combine the first two into one. For example, wrap them in LinearLayout

    1. The lines between the list items are a divider . You can remove them ... removing them :

       android:divider="@null" 

      and this line should also be removed: android:dividerHeight="1dp" . Or prescribe 0