0

使用RelativeLayout我可以在兩個列表頂部並排顯示一個靜態按鈕,但只顯示左側列表視圖。使用上面的靜態按鈕的兩個列表視圖

如果我把這兩個listvies放在線性佈局中,它們似乎也不能正確顯示。

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

    <Button 
     android:id="@+id/new_page" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:text="@string/myButton"/> 

     <ListView 
      android:id="@+id/list_view_left" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_below="@id/new_page" 
      android:layout_alignParentLeft="true" 
      android:layout_toLeftOf="@+id/list_view_right" 
      android:paddingRight="5dp" 
      android:scrollbars="none" > 
     </ListView> 

     <ListView 
      android:id="@id/list_view_right" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_below="@id/new_page" 
      android:layout_alignParentRight="true" 
      android:paddingLeft="5dp" 
      android:scrollbars="none" > 
     </ListView> 

</RelativeLayout> 

回答

0

如果問題沒有解決,您可以使用幀佈局。請參閱here如何使用框架佈局。

0

添加

機器人:layout_toRightOf = 「@ + ID/list_view_left」

你的第二個列表視圖(即在右側)。

您將開始查看第二個列表視圖。

由於寬度是包裝內容,因此您需要注意列表視圖1中每個項目的寬度,否則您將無法看到其他列表視圖。