开发者

Android ListView is not expanding as intended

My scenario is like this:

<ScrollView     
   android:layout_width="fill_parent"
   android:layout_height="fill_parent"      
   android:scrollbars="vertical"        
   android:background="#ffffeb">

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

      // Other stuff in between here..

      <LinearLayout
         android:orientation="vertical"   
         android:layout_width="fill_parent"   
         android:layout_height="fill_parent"   
         android:paddingLeft="12dp"   
         android:paddingRight="12dp">

         <Button 
            android:id="@+id/insert_ad_ad_information_category_and_type_button"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="6dp"
            android:text="@string/insert_ad_ad_information_category_and_type_button"/>

         <ListView
            android:id="@+id/insert_ad_ad_information_parameters_frame"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:background="#ffffeb"
            android:cacheColorHint="#00000000"
            android:divider="#00000000"
            android:dividerHeight="0dp"
            android:scrollbars="none"
            android:listSelector="@android:color/transparent"/>

The problem I have is that I can't get my ListView to get the right height that I want.

I'll add a couple of components with my custom BaseAdapter class and everything there works as intended.

But when I then debug my application I can only see 1,5 out of 3 components in the list and the rest is hidden further down in the ListView.

But how can I make my ListView calculate how many components I have and get it to show all my components directly without hav开发者_开发知识库ing too scroll down?

Another thought is if I could populate any other kind of View with my BaseAdapter? Because the only reason I am using ListView is because of the setAdapter() method.

Appreciate all thoughts and comments :)


You cannot have a ListView in a ScrollView. Thats where the issue is.


As has been said you can't use ListView inside ScrollView. If you want your listview have different types of items and scroll those with "normal" items you do in fact need custom adapter. You can base it on BaseAdapter if you like Adapter has to support your item types, and inflate appropriate layouts,

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜