简体   繁体   中英

Supporting Different Screen Orientation & Different drawable images for multi screens

How can I understand to implement different layout,drawable for different screen orientation ? If you have any example regarding this please post here. And also for inserting icons in my layout I will have to insert for all sizes ?? How to do that ?

I read Google documentation but it doesn't solved my problem!

I need an example to understand.Kindly help.

Thanks.

You can use Google library PercentRelativeLayout with this library you can set width , height and margin of your views by percentage which is great because in all screen they look the same(for your case they look good for landscape and portrait screen orientation) and of course it is not hard to code it. Here example:

<android.support.percent.PercentRelativeLayout
         xmlns:android="http://schemas.android.com/apk/res/android"
         xmlns:app="http://schemas.android.com/apk/res-auto"
         android:layout_width="match_parent"
         android:layout_height="match_parent">
     <ImageView
         app:layout_widthPercent="50%"
         app:layout_heightPercent="50%"
         app:layout_marginTopPercent="25%"
         app:layout_marginLeftPercent="25%"/>
 </android.support.percent.PercentRelativeLayout>

you must add this line in your build.gradle

dependencies {
    compile 'com.android.support:percent:23.2.0'
}

Official documentation by Google https://developer.android.com/reference/android/support/percent/PercentRelativeLayout.html

Hope this help for your case!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM