Is there a way to set a GUI screen (Activity) to be 200dip wide and 150dip high, either using XML or programmatically?
I found getWindow().setLayout(), but that only take predefined constants for width and height.
Display display = getWindowManager(). getDefaultDisplay(); Point size = new Point(); display. getSize(size); int width = size. x; int height = size.
I've found a way to know the exact height of my activity: if you have a view filling all the available screen behind the title bar and the task bar, just use View. getBottom() to get the real height of that activity.
You can use absolute numbers in Window.setLayout(), just like you can everywhere else you specify layout width and height. Sorry the doc isn't clear on this.
WindowManager.LayoutParams params = getWindow().getAttributes();
params.x = 0;
params.height = 650;
params.width = totalWidth;
params.y = totalHeght/10;
this.getWindow().setAttributes(params);
may be it works...but make sure about the values...
Just use a full screen layout, and inside define another layout that has the size you want. Kind of like this:
<?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">
<LinearLayout android:layout_width="200dip"
android:layout_height="150dip">
<Button android:text="Button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
</LinearLayout>
I put a button in there just to show where the content goes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With