2015-12-30 135 views
0

我有一个包含另一个布局B的布局A,但A重叠了B,因此B的一部分未显示。布局重叠包含布局

这是布局B:

enter image description here

,这是源代码:

<?xml version="1.0" encoding="utf-8"?> 
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 

    <ListView 
     android:id="@+id/listView" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentStart="true" 
     android:layout_alignParentTop="true" /> 
</RelativeLayout> 

和布局答:

enter image description here

及其源:

<?xml version="1.0" encoding="utf-8"?> 
<android.support.design.widget.CoordinatorLayout 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:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fitsSystemWindows="true" 
    tools:context="com.byte64.i_assembly.activity.BillDetailActivity"> 

    <android.support.design.widget.AppBarLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:theme="@style/AppTheme.AppBarOverlay"> 

     <android.support.v7.widget.Toolbar 
      android:id="@+id/toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="?attr/actionBarSize" 
      android:background="?attr/colorPrimary" 
      app:popupTheme="@style/AppTheme.PopupOverlay" /> 

    </android.support.design.widget.AppBarLayout> 

    <include layout="@layout/test_layout" /> 

    <android.support.design.widget.FloatingActionButton 
     android:id="@+id/fab" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="bottom|end" 
     android:layout_margin="@dimen/fab_margin" 
     android:src="@drawable/ic_action_download" /> 

</android.support.design.widget.CoordinatorLayout> 

正如你所看到的,列表中的第一项是隐藏的。我该如何解决这个问题?我玩过两种布局的layout_heightlayout_width,但没有运气。

回答

0

像这样使用你的test_layout。与您的布局要显示的tools:context=".MainActivity"

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout 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:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:paddingBottom="@dimen/activity_vertical_margin" 
    android:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" 
    android:paddingTop="@dimen/activity_vertical_margin" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior" 
    tools:context=".MainActivity" 
    tools:showIn="@layout/activity_main"> 

    <ListView 
     android:id="@+id/listView" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentStart="true" 
     android:layout_alignParentTop="true" /> 
</RelativeLayout> 
  • 变化值。
  • ,如果你不使用的辣油
+0

谢谢,但这并没有帮助。 –

0

默认名称tools:showIn="@layout/activity_main"更改布局的名字,你应该添加xmlns:app="http://schemas.android.com/apk/res-auto"app:layout_behavior="@string/appbar_scrolling_view_behavior"RelativeLayout的其中wrapp的ListView,这个工作对我来说

+0

试过了。没有改变 –

0

试试这个出...

<android.support.v4.widget.NestedScrollView 
     android:id="@+id/scrollView" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 

<!-- include your layout--> 

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