Reputation: 758
I am working on a project in which many views are generated dynamically and apps will be running on different screen size. So is there any way to take care of the screen size in the code while views are generating dynamically and apps is running on different devices. Thanx in advance
Upvotes: 4
Views: 1317
Reputation: 327
If you want to be really specific then use:
DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
Then you can specify in IF statements what screen pixels you want to change your layout for, in certain ways.
Upvotes: 1
Reputation: 15701
Try something like
LayoutParams p = new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.FILL_PARENT);
txtView.setLayoutParams(p);
http://developer.android.com/guide/practices/screens_support.html
use WRAP_CONTENT or FILL_PARENT not fix no for hieght and width
use dp and sp as unit
Provide different bitmap drawables for different screen densities
Provide different layouts for different screen sizes
Upvotes: 0
Reputation:
yes, it's possible that.
GO to AndroidManifiest.xml file - > Manifiest Tab - > Add Screen supports . and you can also seen that in last AndroidManifiest.xml Tab like this .
< supports-screens
android:xlargeScreens="true"
android:resizeable="true"
android:normalScreens="true"
android:anyDensity="true"
android:smallScreens="true"
android:largeScreens="true"/>
Upvotes: 0