I've a problem with dialog display dimension. With following code i make my custom dialog with ScrollView inside, but when it shown, ScrollView fit dialog dimension, but the inside linear layout has some controls out of scrollable area. I can't understand why and how to resolve.
Into phone with little display it's a problem because some controls are unreachable.
Dialog creation:
AlertDialog.Builder alert = new AlertDialog.Builder(DataMainPage.this);
startNewTestSessionDialog = new StartTestDialog(DataMainPage.this);
alert.setView(startNewTestSessionDialog);
alert.setPositiveButton("Start", new DialogInterface.OnClickListener() {<...>});
alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {<..>});
Dialog d = alert.create();
WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
lp.copyFrom(d.getWindow().getAttributes());
lp.width = WindowManager.LayoutParams.MATCH_PARENT;
lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
d.show();
d.getWindow().setAttributes(lp);
Dialog view xml:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:sample="http://schemas.android.com/apk/res/ips.tecnos.saildata"
android:id="@+id/startTest_dialogView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="65dp"
android:fillViewport="true" >
<LinearLayout
android:id="@+id/startTest_viewContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:clipToPadding="false"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="horizontal"
android:weightSum="2"
android:layout_marginBottom="5dp" >
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:layout_marginRight="7dp"
android:gravity="right|center_vertical"
android:text="@string/testStart_disableWind"
android:textAppearance="?android:attr/textAppearanceMedium" />
<CheckBox
android:id="@+id/startTest_disableWind"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:gravity="center"
android:text="" />
</LinearLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:gravity="center"
android:layout_marginTop="10dp"
android:text="@string/testStart_boatType"
android:textAppearance="?android:attr/textAppearanceMedium" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="horizontal"
android:weightSum="3"
android:layout_marginBottom="5dp" >
<Spinner
android:id="@+id/startTest_boatSelect"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center|right"
android:layout_weight="2"
android:gravity="center|right" />
<Button
android:id="@+id/startTest_modifyBoatPolar"
android:layout_width="0dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="@string/testStart_modboatPolar" />
</LinearLayout>
<...other controls with same logic...>
</LinearLayout>
</ScrollView>
Screenshoot (Nexus5): ScrollView is at its end, and as you can see button and hidden spinner is out of scrollView border. Screnshoot