开发者

separate layout equally

开发者 https://www.devze.com 2023-03-15 03:51 出处:网络
I\'ve got this code that i\'m working on : <?xml version=\"1.0\" encoding=\"utf-8\"?> <RelativeLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"

I've got this code that i'm working on :

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:weightSum="3"
android:id="@+id/main"
>
<RelativeLayout
    android:layout_width="330dp"
    android:layout_height="fill_parent"
    android:layout_weight="1"
    android:id="@+id/linear1"
>
    <TextView 
        android:text="List1"
        android:textSize="40px"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/shows_text"
    />
    <ListView 
        android:layout_height="wrap_content" 
        android:id="@+id/listView1" 
        android:layout_width="fill_parent" 
        android:layout_below="@id/shows_text"
    />开发者_如何学Python;
</RelativeLayout>
<RelativeLayout 
    android:layout_width="330dp" 
    android:layout_height="fill_parent"
    android:layout_weight="1"
    android:id="@+id/linear2"
    android:layout_toRightOf="@id/linear1"
>
    <TextView 
        android:text="List2"
        android:textSize="40px"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/seasons_text"
    />
    <ListView 
        android:layout_height="wrap_content" 
        android:id="@+id/listView2" 
        android:layout_width="fill_parent"
        android:layout_below="@id/seasons_text"         
    />
</RelativeLayout>
<RelativeLayout 
    android:layout_width="330dp" 
    android:layout_height="fill_parent"
    android:layout_weight="1"
    android:id="@+id/linear3"
    android:layout_toRightOf="@id/linear2"
>
    <TextView 
        android:text="List3"
        android:textSize="40px"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/episodes_text"
    />
    <ListView 
        android:layout_height="wrap_content" 
        android:id="@+id/listView3" 
        android:layout_width="fill_parent"
        android:layout_below="@id/episodes_text"
    />
</RelativeLayout>

   </RelativeLayout>

And this layout doesn't seperate the listview equally, i tried to pu some weight on the layouts but there is a little space that i can't get rid of .


For using layout_weight property properly... use parent root layout as LinearLayout and set its orientation as horizontal. I guess that can solve your problem.


Change the layout_width to 0dip when you are using weight to have them automatically sized. Also, you may want to change the layout_width of your TextViews to fill_parent to be consistent with the width of your listview.

0

精彩评论

暂无评论...
验证码 换一张
取 消