Question If I have the following:
I ran across a link to the mail app source code in my accepted answer on another question. The answer is simple! Add android:fillViewport="true"
to the <ScrollView...>
and add android:layout_weight="1.0"
to the view you want to take up all the available space. explained in this blogspot
Why don't you make the ScrollView being fill_parent and A and B to wrap_content ? The only thing you want is that your ScrollView fits the screen.
after you call
AlertDialog dialog = builder.show();
then call
fixScrollViewHeight(scrollView);
private void fixScrollViewHeight(ScrollView scrollView)
{
int screenHeight = activity.getWindowManager().getDefaultDisplay().getHeight();
LayoutParams lp = scrollView.getLayoutParams();
lp.height = screenHeight / 3;
scrollView.setLayoutParams(lp);
}
As mentioned above the right way is to use the android:fillViewport="true" attribute.
There is an example, where the image will be positioned at the and of scrollView:
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:fillViewport="true"
android:orientation="vertical">
<LinearLayout
android:layout_height="fill_parent"
android:layout_width="wrap_content"
android:orientation="vertical"
android:layout_weight="1">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="test"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@color/red">
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:src="@drawable/about_us_image_1_land"
style="@style/layout_marginTop20"/>
</LinearLayout>
</LinearLayout>
</ScrollView>