Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
98 views
in Technique[技术] by (71.8m points)

java - Can we make one Layout type for all screen size

I developed apps using multiple layouts types for different screens types and resolutions but I have notices that some developers using only one layout type,Which one is a better practices to continue with Single or Multiple layout type?

Multiple layout type like

layout-large-mdpi   
layout-large-tvdpi  
layout-large-xhdpi 
layout-xlarge-mdpi  
layout-xlarge-xhdpi 
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Using different dimens files you can do this thing.

values-mdpi ->dimens.xml

values-hdpi ->dimens.xml

values-xhdpi ->dimens.xml

values-xxhdpi ->dimens.xml

For example: define one in values-mdpi ->dimens.xml

<dimen name="scale_1dp">10dp</dimen>

and for values-hdpi ->dimens.xml

<dimen name="scale_1dp">12dp</dimen>

and for values-xhdpi ->dimens.xml

<dimen name="scale_1dp">15dp</dimen>

And after that use this dimen

<ImageView
     android:layout_width="@dimen/scale_1dp"
     android:layout_height="wrap_content"
     android:layout_gravity="center"/>

same thing for text size.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...