I put the activity set android: theme = "@ android: style / Theme.Dialog" window mode, but after opening the window width and height are the size of the control with the activity and change, and I want this window size set to a fixed value, regardless of how the size of the controls inside are the same, the method I used is:
WindowManager m = getWindowManager ();
Display d = m.getDefaultDisplay (); / / to get the screen width and height ;
LayoutParams p = getWindow (). getAttributes (); / / get the current value of the parameter dialog
p.height = (int) (d.getHeight () * 1.0); / / height is set to screen 1.0
p.width = (int) (d.getWidth () * 0.7); / / set the width of the screen is 0.8
p.alpha = 1.0f; / / Set the transparency itself
p.dimAmount = 0.0f; / / set the dark level
getWindow (). setAttributes (p);
but the effect is still the same, what dialog is kind of how this mechanism? This is not an internal layout comes up? Is there any way around this?
------ Solution ---------------------------------------- ----
android.view.ViewGroup.MarginLayoutParams ml = (MarginLayoutParams) rLayout.getLayoutParams ();
ml.height = converHeight (num) + 1;
rLayout.setLayoutParams (ml);
done a similar thing, hoping to inspire you.
------ Solution ---------------------------------------- ----
change the layout with LinearLayout layout and set
android: layout_width = "fill_parent"
android: layout_height = "fill_parent"
or by getting LinearLayout ID number,
set p.height = (int) (d.getHeight () * 1.0); and p.width = (int) (d.getWidth ( ) * 0.7); LinearLayout time while changing the width and height.
------ Solution ---------------------------------------- ----
suppose your layout file inside LinearLayout ID for myLinearLayout, then by setting
myLinearLayout.setLayoutParams (new LayoutParams ((int) (d.getWidth () * 0.7), (int) (d.getWidth () * 0.7 ));
------ For reference only ----------------------------------- ----
their own roof first
------ For reference only --------------------------- ------------
more points you can say? rLayout which instance?
------ For reference only ------- --------------------------------
I returned ML is null
- ---- For reference only ---------------------------------------
< br /> I just put P added to linearlayout go inside, but the real effect is still no
------ For reference only ------------------- --------------------
ah, you can, in front of the mistakes in the outermost linearlayout to set the width and height, and have the outermost linearlayout then add a linearlayout on it
------ For reference only ------------------------- --------------
I ask, I get the dialog also recently theme activity, my activity will be under the control of the different changes inside width and height, do you know how different width and height for each case, the width and height data do?
------ For reference only ----------------------- ----------------
landlord stupid friends!
WindowManager m = getWindowManager ();
Display d = m.getDefaultDisplay (); / / to get the screen width and height ;
LayoutParams p = getWindow (). getAttributes (); / / get the current value of the parameter dialog
p.height = (int) (d.getHeight () * 1.0); / / height is set to screen 1.0
p.width = (int) (d.getWidth () * 0.7); / / set the width of the screen is 0.8
p.alpha = 1.0f; / / Set the transparency itself
p.dimAmount = 0.0f; / / set the dark level
getWindow (). setAttributes (p);
In setContentView () is called after Jiuhaola!
------ For reference only -------------------------------------- -
like this one, upstairs to the force
没有评论:
发表评论