Dynamic views for different screen sizes

I am working on a project in which many views are generated dynamically, and applications will run on different screen sizes. Thus, is there a way to take care of the screen size in the code, while the views are generated dynamically and the applications work on different devices. Thanks in advance

+4
source share
3 answers

If you want to be really specific, use:

DisplayMetrics metrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(metrics); Then you can specify in the IF statements which pixels of the screen you want to change your layout in certain ways.

+1
source

yes it is possible that.

Go to the AndroidManifiest.xml file → Tab “Manifiest” → “Add Screen”. and you can also see that in the last tab of AndroidManifiest.xml like this.

<screen support

  android:xlargeScreens="true" android:resizeable="true" android:normalScreens="true" android:anyDensity="true" android:smallScreens="true" android:largeScreens="true"/> 
0
source

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, fix no for hieght and width

use dp and sp as unit

Provide various bitmap drawings for different screen densities.

Providing different layouts for different screen sizes

0
source

Source: https://habr.com/ru/post/1411954/


All Articles