2017-09-10 8 views
0

IDチャットを持つ最後のビューグループが前のビューグループと重なり、自分の電話機の画面全体を占有したいと考えています。以下のXMLコードで、私はそれが私が望むものを得るだろうと推測します。しかし、コードはそうではありません。助けてください。android relativelayout:最後のビューグループはヘッダーを越えませんか?

以下はxmlコードです。

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:id="@+id/root" 
android:orientation="vertical" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
tools:context="com.testapp.MainActivity"> 
<LinearLayout 
    android:id="@+id/bar" 
    android:layout_alignParentStart="true" 
    android:orientation="horizontal" 
    android:gravity="center_vertical" 
    android:background="#999999" 
    android:elevation="10dp" 
    android:layout_width="match_parent" 
    android:layout_height="40dp"> 
    <ImageView 
     android:id="@+id/bar_img" 
     android:src="@drawable/ic_autorenew_black_24dp" 
     android:gravity="clip_vertical" 
     android:paddingStart="8dp" 
     android:layout_width="36dp" 
     android:layout_height="36dp" /> 
    <TextView 
     android:id="@+id/bar_title" 
     android:text="title" 
     android:ellipsize="end" 
     android:layout_weight="1" 
     android:gravity="center" 
     android:textColor="#ffffff" 
     android:textStyle="bold" 
     android:textSize="18sp" 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" /> 
</LinearLayout> 
<FrameLayout 
    android:id="@+id/root_frag" 
    android:layout_below="@id/bar" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"></FrameLayout> 
<LinearLayout 
    android:id="@+id/chats" 
    android:background="#ea2312" 
    android:orientation="vertical" 
    android:layout_alignParentStart="true" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 
    <LinearLayout 
     android:id="@+id/chat_list" 
     android:orientation="vertical" 
     android:layout_width`enter code here`="match_parent" 
     android:layout_height="wrap_content"> 
     <TextView 
      android:text="hello world" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" /> 
    </LinearLayout> 
</LinearLayout> 
</RelativeLayout> 

これはプレビューのスクリーンショットです。

enter image description here

答えて

0

「チャット」LinearLayoutないは、画面全体を埋めるが、「バー」LinearLayoutは、そのandroid:elevation属性の(それがRelativeLayout内で先に定義されていても)、その上に表示されます。

これを停止するには、「バー」ビューからelevation attrを削除するか、「チャット」ビューに(大きい)elevation attrを追加します。

関連する問題