=============== Problem description ====================
Recently, some developers have encountered some inexplicable problems. Is it a matter of swelling to set the Custom Size of dialog butes? I just want to display a part of dialog, but the full screen is full, which is hard to understand, I used to write it in this way. Now I can't do it anymore.
This is the code of dialog.
DownLoaderDialog dialog=new DownLoaderDialog(MainActivity.this,R.style.dialog);Window mwindow=dialog.getWindow();WindowManager.LayoutParams lp=mwindow.getAttributes();int[] location = new int[2];button.getLocationOnScreen(location);WindowManager m = getWindowManager();Display d = m.getDefaultDisplay();lp.y=location[1];lp.height = (int) (d.getHeight() * 0.6);mwindow.setAttributes(lp);dialog.show();
This is the XML of dialog.
<? XML version = "1.0" encoding = "UTF-8"?> <Linearlayout xmlns: Android = "http://schemas.android.com/apk/res/android" Android: layout_width = "fill_parent" Android: layout_height = "fill_parent" Android: Orientation = "vertical"> <linearlayout Android: layout_width = "match_parent" Android: layout_height = "0px" Android: layout_weight = "1" Android: Background = "# eceff0"> <listview Android: id = "@ + ID/listview1" Android: layout_width = "match_parent" Android: layout_height = "wrap_content"> </listview> </linearlayout> <linearlayout Android: layout_width = "match_parent" Android: layout_height = "50dp" Android: Background = "#0ba683" Android: gravity = "center_vertical" Android: Orientation = "horizontal"> <button Android: id = "@ + ID/btndelete" Android: layout_width = "0px" Android: layout_height = "match_parent" Android: layout_weight = "1" Android: background = "@ drawable/btn_pressed_style" Android: text = "delete" Android: textcolor = "# fdfefe" Android: textsize = "16sp"/> <view Android: layout_width = "1dp" Android: layout_height = "match_parent" Android: Background = "# dad1_"/> <button Android: Id =" @ + ID/btnselectall "Android: layout_width = "0px" Android: layout_height = "match_parent" Android: layout_weight = "1" Android: Background = "@ drawable/btn_pressed_style" Android: text = "all" Android: textcolor = "# fdfefe" Android: textsize = "16sp"/> </linearlayout>
============= Solution 1 ======================
<Linearlayout xmlns: Android = "http://schemas.android.com/apk/res/android"
Android: layout_width = "fill_parent" Try wrap_content
Android: layout_height = "fill_parent"
Android: Orientation = "vertical">
============= Solution 2 ======================
A strange way of writing.
============= Solution 3 ======================
The problem should be found in R. style. dialog.
I have encountered some inexplicable problems in recent development. The Custom Size of dialog butes is not reflected in setattributes. Is it swollen?