Drawerlayout孩子的意见重叠 [英] Drawerlayout children views overlapping

查看:137
本文介绍了Drawerlayout孩子的意见重叠的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直试图做一个 DrawerLayout 具有 ViewPager 的LinearLayout 连接到 DrawerLayout 的底部。问题是, ViewPager 的LinearLayout 是我所有的努力,将重叠在视图的顶部, 的LinearLayout 下跌到目前为止还没有。

I've been trying to make a DrawerLayout that has a ViewPager and a LinearLayout attached to the bottom of the DrawerLayout. The problem is that the ViewPager and LinearLayout are overlapping at the top of the view, and all my efforts to move the LinearLayout down have failed so far.

中的XML布局:

<?xml version="1.0" encoding="utf-8"?>
<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.support.v4.view.ViewPager
            android:id="@+id/viewpager"
            android:layout_width="match_parent"
            android:layout_height="0dp" >

            <android.support.v4.view.PagerTabStrip
                android:id="@+id/tabstrip"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content" />
        </android.support.v4.view.ViewPager>

        <LinearLayout
            android:id="@+id/linear_layout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_below="@id/base_activity_viewpager"
            android:orientation="vertical" >

            <TextView
                android:id="@+id/textview"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:textAppearance="@android:style/TextAppearance.Medium"
                android:textIsSelectable="false" />
        </LinearLayout>

        <!-- Naviagtion drawer -->

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

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

我已经尝试添加几件事情linear_layout:

I've tried adding several things to linear_layout:

  1. 安卓layout_gravity =底部(会导致一个IllegalStateException)
  2. 安卓layout_below =@ ID / viewpager
  3. 安卓layout_alignparentbottom =真正的
  1. android:layout_gravity="bottom" (causes an IllegalStateException)
  2. android:layout_below="@id/viewpager"
  3. android:layout_alignparentbottom="true"

不过,所有这些值似乎被忽略,甚至改变的android:layout_width 的LinearLayout 被忽略。我想我忽视的东西明显,但如果任何人有关于如何做到这一点建议,那将是极大的AP preciated。

But all of these values seem to be ignored, even changing android:layout_width of the LinearLayout is ignored. I think i'm overlooking something obvious but if anyone has suggestions on how to do this it would be greatly appreciated.

推荐答案

一个drawerlayout只允许2个孩子,第一个是主要内容来看,第二个是抽屉。您需要将前两个观点结合成一个线性布局。 <一href="http://developer.android.com/training/implementing-navigation/nav-drawer.html">http://developer.android.com/training/implementing-navigation/nav-drawer.html

A drawerlayout is allowed only 2 children, the first is a main content view, the second is the drawer. You need to combine your first two views into a linear layout. http://developer.android.com/training/implementing-navigation/nav-drawer.html

这篇关于Drawerlayout孩子的意见重叠的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆