2017-10-12 82 views
0

我有布局:为什么片段超过textView?

<RelativeLayout 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     xmlns:tools="http://schemas.android.com/tools" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_alignParentTop="true" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentStart="true"> 


     <fragment xmlns:android="http://schemas.android.com/apk/res/android" 
      android:id="@+id/frag1" 
      class="com.luheb.cars.LastListFragment" 
      android:layout_width="wrap_content" 
      android:layout_height="match_parent" 
      android:layout_alignParentLeft="true" 
      android:layout_alignParentStart="true" 
      tools:layout="@layout/frag1" /> 

     <TextView 
      android:id="@+id/textView" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:text="test" 
      android:layout_alignParentBottom="true" /> 

    </RelativeLayout> 

在片段我有ListView,如果我在TextView单击然后的onclickListView呼吁。

我想TextView有底部和fragmentListView应该从顶部到TextView。现在fragment是自上而下和TextView是粘底...

+0

尝试增加属性'layout_below'您的TextView。 –

+0

与layout_below我没有看到我的TextView ... – luheb

回答

1

android:layout_above尝试。

将此视图的底部边缘放置在给定锚点视图ID上方。 适应此视图的底部边距和锚视图的顶部边距。

最后

<fragment xmlns:android="http://schemas.android.com/apk/res/android" 
     android:id="@+id/frag1" 
     class="com.luheb.cars.LastListFragment" 
     android:layout_width="wrap_content" 
     android:layout_height="match_parent" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentStart="true" 
     tools:layout="@layout/frag1" 
     android:layout_above="@+id/textView" /> 

     <TextView 
     android:id="@+id/textView" 
     android:layout_width="match_parent" 
     android:layout_height="25dp" 
     android:text="test" 
     android:layout_alignParentBottom="true" /> 
0

添加此行到您的片段:

android:layout_above="@+id/textView"