I am creating some AlertDialog using the v7 support library 22.1.1 (as I want to support Android 2.3 as well):
import android.support.v7.app.AlertDialog;
//import android.app.AlertDialog;
LayoutInflater inflater = (LayoutInflater) parent.getSystemService( Context.LAYOUT_INFLATER_SERVICE );
View messageView = inflater.inflate(R.layout.dialog_dialog1, null, false);
AlertDialog.Builder builder = new AlertDialog.Builder(parent);
builder.setIcon(R.drawable.ic_action_important);
builder.setTitle(parent.getString(R.string.action_action1));
builder.setView(messageView);
feedbackMessageDialog = builder.create();
builder.show();
Everything is fine for most of the dialogs. However, a specific dialog is shown with a height of almost the whole screen, in spite of it having the wrap_content value and the content only filling half of the screen.
The themes I am using in my activities are Theme.AppCompat.NoActionBar and Theme.AppCompat. This issue is happening with both themes.
If I use the standard AlertDialog (android.app.AlertDialog) instead of the one from the support library, the dialog is rendered correctly.
The main difference with dialogs that are working fine with the support library is that this one uses a TableLayout:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="20dip"
android:scrollbars="vertical"
android:background="@android:color/transparent"
android:scrollbarAlwaysDrawVerticalTrack="true">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/text_main"
android:id="@+id/textView"
android:layout_gravity="center_horizontal"
android:gravity="center"
android:columnCount="2"
android:textColor="@android:color/primary_text_dark" />
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:gravity="center">
<TableRow android:gravity="center"
android:background="@drawable/background_material_dark_button"
android:layout_marginTop="20dp"
android:clickable="true"
android:focusable="true"
android:onClick="doAction1">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageButtonPositive"
android:background="@drawable/ic_action_1"
android:contentDescription="@string/desctext1"
android:layout_gravity="center"
android:minHeight="64dp"
android:minWidth="64dp" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/feedback_good_text"
android:id="@+id/textView2"
android:gravity="center_vertical"
android:layout_gravity="center_vertical"
android:layout_weight="1" />
</TableRow>
<TableRow android:gravity="center"
android:layout_marginTop="20dp"
android:clickable="true"
android:focusable="true"
android:onClick="doAction2"
android:background="@drawable/background_material_dark_button">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageButtonNegative"
android:background="@drawable/ic_action_2"
android:contentDescription="@string/desctext2"
android:baselineAlignBottom="false"
android:minHeight="64dp"
android:minWidth="64dp"
android:layout_gravity="center" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/feedback_bad_text"
android:id="@+id/textView3"
android:gravity="center_vertical"
android:layout_gravity="center_vertical"
android:autoText="false"
android:elegantTextHeight="false"
android:layout_weight="1" />
</TableRow>
</TableLayout>
</LinearLayout>
This seems to be a bug in the support library, which I have logged in the appropriate tracker: http://code.google.com/p/android/issues/detail?id=172279
May there be something missing in the definition of my layout that triggers the issue, or may there be a way to workaround the issue?
It may probably be possible to get a similar layout with just LinearLayout (which are working fine).