I have a custom dialogue with the list. When you first start the dialogue, the indents in height are ignored and some of the elements are not visible. On subsequent launches, everything is in order . I have no idea what can help in solving the problem, I bring a bunch of different code, it may come in handy.
Dialog code:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" > <ListView android:id="@+id/lvMultiChoice" android:divider="@color/backgr" android:dividerHeight="1dp" android:layout_marginLeft="10dp" android:layout_marginRight="10dp" android:drawSelectorOnTop="false" android:layout_width="match_parent" android:layout_height="wrap_content" > </ListView> </LinearLayout>
The button is put in the list's footer, in fact, usually it’s not visible (partially visible):
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_height="wrap_content" android:layout_width="match_parent" android:orientation="horizontal"> <Button android:id="@+id/btnDialogOk" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="OK" android:layout_weight="1" android:background="@drawable/button_grey" android:layout_marginTop="10dp" android:layout_marginBottom="10dp" /> </LinearLayout>
I create a dialogue like this:
dialogMultiChoice = new Dialog(this,R.style.AppTheme_Dialog); dialogMultiChoice.setContentView(R.layout.dialog_multichoice); ListView lvMultiChoice = (ListView) (dialogMultiChoice.findViewById(R.id.lvMultiChoice)); View v = getLayoutInflater().inflate(R.layout.lv_footer_btn_ok, null); lvMultiChoice.addFooterView(v,null,false); dialogMultiChoice.getWindow().setTitleColor(getResources().getColor(R.color.backgr)); dialogMultiChoice.setTitle(Fragment_Filter.adapterFilter.names[id]); adapMeal = new MultiChoiceAdapter(Samo_Data.MEAL); lvMultiChoice.setAdapter(adapMeal); dialogMultiChoice.getWindow().setLayout(lp.width, lp.height); return dialogMultiChoice;
The topic that is used when creating the dialogue:
<style name="AppTheme.DialogTitle"> <item name="android:textSize">16pt</item> <item name="android:textColor"> @android :color/black</item> <item name="android:gravity">center</item> </style> <style name="AppTheme.DialogWindowTitle"> <item name="android:maxLines">1</item> <item name="android:textAppearance"> @style /AppTheme.DialogTitle</item> </style> <style name="AppTheme.Dialog"> <item name="android:windowTitleStyle"> @style /AppTheme.DialogWindowTitle</item> </style>