问题描述
我正在使用以下布局.基本上,它具有一个自定义工具栏,一个导航抽屉,一个菜单,一个ListView(listView1)和adlay.
I am using the following layout. Basically, it has a custom toolbar, a Navigation Drawer, a menu, a ListView (listView1), and adlay.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/background">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="@color/header_bg"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/toolbar">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="@+id/listView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="start"
android:layout_above="@+id/adlay"
android:layout_margin="7dp"
android:cacheColorHint="#00000000"
android:divider="@android:color/transparent"
android:dividerHeight="3dp">
</ListView>
<LinearLayout
android:id="@+id/adlay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="vertical" >
</LinearLayout>
</RelativeLayout>
<ListView
android:id="@+id/drawer_list"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:choiceMode="singleChoice"
android:divider="#eee"
android:dividerHeight="1dp"
android:background="#fff"
android:layout_below="@+id/toolbar"
>
</ListView>
</android.support.v4.widget.DrawerLayout>
</RelativeLayout>
布局有点像以下顺序:
- 工具栏(带有导航抽屉和菜单)
- listView1
- adlay
listView1包含从外部XML文件加载的项目的列表.
listView1 consists of a list of items loaded from external XML files.
问题是这个.如果listView1的项目不多,则它会下降到底部,位于adlay上方,并且在工具栏和listView1之间的listView1上方有一个缝隙.显示如下:
Problem is this. If listView1's items is not much, then it drops to the bottom, sitting above adlay, and there is a gap above listView1, between the toolbar and listView1. The display is like the following:
- 工具栏(带有导航抽屉和菜单)
- GAP! < ---我不希望差距在这里!
- listView1
- adlay
这不是所需的显示.
理想情况下,我想要以下内容:
Ideally, I want the following:
- 工具栏(带有导航抽屉和菜单)
- listView1
- GAP应该在这里
- adlay
我们非常感谢您的帮助.谢谢.
Any help is much appreciated. Thanks.
推荐答案
我将根据您的要求编写一个布局文件.我希望它有用
i will write one layout file for your requirement. i hope it's usefull
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@android:color/white">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="@android:color/black"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"/>
<android.support.v4.widget.DrawerLayout
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/toolbar">
<LinearLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ListView
android:id="@+id/listView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="start"
android:layout_weight="1"
android:cacheColorHint="#00000000"
android:divider="@android:color/transparent"
android:dividerHeight="3dp">
</ListView>
<LinearLayout
android:id="@+id/adlay"
android:layout_marginTop="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Your Adlay Layout"/>
</LinearLayout>
</LinearLayout>
<ListView
android:id="@+id/drawer_list"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_below="@+id/toolbar"
android:layout_gravity="start"
android:background="#fff"
android:choiceMode="singleChoice"
android:divider="#eee"
android:dividerHeight="1dp">
</ListView>
</android.support.v4.widget.DrawerLayout>
</RelativeLayout>
这篇关于ListView下降到底部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!