I have encountered some inexplicable problems in recent development. The Custom Size of dialog butes is not reflected in setattributes. Is it swollen?

Source: Internet
Author: User

=============== 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?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.