Skip to content Skip to sidebar Skip to footer

Listview With A Diffrent Number Of Textview In Android

I want to create a layout that will have n numbers of textview on the left side and have listView on the right side .And the top of right side have above listview i need to have t

Solution 1:

Change your child linear layout orientation to horizontal

   <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >
        <TextView
            android:id="@+id/txtBrand"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:gravity="center"
            android:text="Brand" />
        <ListView
            android:id="@+id/subCategory"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="6"
            android:cacheColorHint="@android:color/transparent"
            android:divider="@android:color/transparent"
            android:fadingEdge="none" />
    </LinearLayout>

Solution 2:

<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:background="@android:color/white">
<LinearLayout
        android:id="@+id/first"
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
    <Button android:layout_weight="0.5"
            android:layout_width="0dp"
            android:layout_height="wrap_content"/>
    <Button android:layout_weight="0.5"
            android:layout_width="0dp"
            android:layout_height="wrap_content"/>
</LinearLayout>
<LinearLayout
        android:id="@+id/second"
        android:orientation="vertical"
        android:layout_below="@+id/first"
        android:layout_width="100dp"
        android:layout_height="match_parent">
    <TextView android:text="AAA" android:layout_width="wrap_content" android:layout_height="wrap_content"/>
    <TextView android:text="AAA" android:layout_width="wrap_content" android:layout_height="wrap_content"/>
    <TextView android:text="AAA" android:layout_width="wrap_content" android:layout_height="wrap_content"/>
    <TextView android:text="AAA" android:layout_width="wrap_content" android:layout_height="wrap_content"/>

</LinearLayout>
<ListView
        android:layout_below="@+id/first"
        android:layout_toRightOf="@id/second"
        android:layout_width="wrap_content"
        android:layout_height="match_parent">

</ListView>
</RelativeLayout>

Post a Comment for "Listview With A Diffrent Number Of Textview In Android"