开发者

Fit size of ListView by content

I try to put a ListView inside a ListView with a BaseAdapter.

The second ListView should not scroll but fit to the size of its content.

The layout of the first ListView looks like that:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView
    android:id="@+id/scroll_view"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:fillViewport="true"
    xmlns:android="http://schemas.android.com/apk/res/android">

       <LinearLayout
            android:id="@+id/cart_frame_root"
            android:layout_width="fill_parent"开发者_开发问答 
            android:layout_height="fill_parent"
            android:orientation="vertical"
            android:gravity="center_horizontal"
            android:background="@drawable/background_green_lines"> 

            <TextView
                android:id="@+id/cartHeadline"
                android:layout_centerInParent="true"
                android:layout_width="fill_parent"
                android:layout_height="40dp"
                android:layout_alignParentTop="true"
                android:background="@drawable/background_gradient"
                style="@style/sgHeadline"
                android:text="Warenkorb"
                android:gravity="center"/>            

          <LinearLayout
                android:id="@+id/cart_frame"
                android:layout_width="fill_parent" 
                android:layout_height="fill_parent"
                android:orientation="vertical"
                android:gravity="center_horizontal">
              <ListView android:layout_height="wrap_content" android:id="@+id/listView1" android:layout_width="match_parent"></ListView>
          </LinearLayout>

         <RelativeLayout
                android:id="@+id/cart_footer"
                android:layout_width="fill_parent" 
                android:layout_height="fill_parent"
                android:orientation="vertical"
                android:gravity="center_horizontal" />              


    </LinearLayout>

</ScrollView>

The layout of the second ListView looks like that:

<LinearLayout android:id="@+id/linearLayout1"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:orientation="vertical"    
    xmlns:android="http://schemas.android.com/apk/res/android">


<TextView android:text="TextView" android:id="@+id/textShopName"
    android:layout_width="wrap_content" android:layout_height="wrap_content">    
    </TextView>
<ListView android:id="@+id/listShops" android:layout_width="fill_parent"
    android:layout_height="0dp" android:layout_weight="1"></ListView>
<TextView android:text="TextView" android:id="@+id/textShopSum"
    android:layout_width="wrap_content" android:layout_height="wrap_content">  
    </TextView>
</LinearLayout>

And this is what it looks like now:

http://i.stack.imgur.com/eB3rt.png

Is that possible? How can I manage that?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜