VictorLS
VictorLS

Reputation: 59

Align the text between 2 list views android linear layout

Im having a little problem trying to aling 2 list views in a linear layout
1 list view(Left) have fix text so the problem is aling the 2 list views when the right list view has more text

Heres the activity code:

lv1 = (ListView) findViewById (R.id.aulalist);
lv2 = (ListView) findViewById (R.id.horariolist);
String [] horarios = res.getStringArray(R.array.horarios); 
lv1.setAdapter(new ArrayAdapter<String> (this, android.R.layout.simple_list_item_1, horarios));
lv2.setAdapter(new ArrayAdapter<String> (this, android.R.layout.simple_list_item_1, aula));

and the layout code:

 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
          android:orientation="horizontal"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"
          >

<LinearLayout
    android:layout_width="169dp"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <ListView
        android:id="@+id/aulalist"
        android:layout_width="169dp"
        android:layout_height="fill_parent"

         />

</LinearLayout>
<LinearLayout android:orientation="vertical"
              android:layout_width="fill_parent"
              android:layout_height="fill_parent"
              android:layout_weight="1"
              >

    <ListView
        android:id="@+id/horariolist"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent" />

</LinearLayout>
 </LinearLayout>

Upvotes: 1

Views: 165

Answers (1)

Marcin S.
Marcin S.

Reputation: 11191

You don't need to enclose your ListView's in LinearLayout. Try this following code:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:orientation="horizontal"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent">

<ListView
    android:id="@+id/aulalist"
    android:layout_width="0dp"
    android:layout_height="fill_parent"
    android:layout_weight="1" >
</ListView>

<ListView
    android:id="@+id/horariolist"
    android:layout_width="0dp"
    android:layout_height="fill_parent"
    android:layout_weight="1" >
</ListView>

Upvotes: 1

Related Questions