I am creating some TextView
, ImageView
, HtmlView
dynamically and adding it in following layout.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/parent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:id="@+id/ad_space"
android:layout_width="fill_parent"
android:layout_height="40dp"
android:background="@drawable/navigation_bar"
android:visibility="gone" >
</LinearLayout>
<ViewFlipper
android:id="@+id/viewflipper"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1" >
<ScrollView
android:id="@+id/quiz_scroll_view"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:id="@+id/quizView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/answer_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" />
</LinearLayout>
</ScrollView>
<ScrollView
android:id="@+id/quiz_scroll_viewTwo"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:id="@+id/quizViewTwo"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/answer_layoutTwo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" />
</LinearLayout>
</ScrollView>
</ViewFlipper>
</LinearLayout>
In QuizView
I am adding some question related views at runtime, and for answers I am creating one list view runtime and adding to answer_layout
. I am using BaseAdapter
to create ListView
runtime based on situation.
But my ListView
is not showing all content, its showing only first cell.
I have adding ListView
like this.
ListView ansList = new ListView(Test.this);
ansList.setAdapter(adapter);
ansList.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
ansCellLayout.addView(ansList);
it display only one list cell.
if I set some int
value for height then its show all list contains.
ansList.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, 600));
But I cant Hardcode list view height as my contant is dynamic.
How to make list view as a WRAP_CONTENT
in this scenario ?