简体   繁体   中英

Android Image on Screen Sizes

I've read about the Android documentation about screen densities and sizes and also looked at some Q&As here at StackOverFlow but I still cannot figure out how to correctly put/create images for my Android project. Say that I have a 300x200px logo and I need to put it on my login screen for my app. I want the logo to look the right size in phones and bigger on tablets. Can anyone give a an example project or tutorial on how I would achieve it. I specifically dont know how I should resize my image in photoshop and which drawable folder to place it in my project.

You need to support all the screen sizes. You can see it here

res/layout/my_layout.xml             // layout for normal screen size ("default")
res/layout-small/my_layout.xml       // layout for small screen size
res/layout-large/my_layout.xml       // layout for large screen size like nexus-7
res/layout-xlarge/my_layout.xml      // layout for extra large screen sizes like tablet

Also add this to your manifest

<supports-screens android:resizeable=["true"| "false"]
          android:smallScreens=["true" | "false"]
          android:normalScreens=["true" | "false"]
          android:largeScreens=["true" | "false"]
          android:xlargeScreens=["true" | "false"]
          android:anyDensity=["true" | "false"]
          android:compatibleWidthLimitDp="integer"
          android:largestWidthLimitDp="integer"/>

You can also use this to guide you. Hope it helps.

More informations about dimension here : developer.android.com/guide/practices/screens_support

But if you don't want to loose time you can do it automatically .

I use the free plugin " Cut and slice me ". You can download it from her official website. Just click on the file to install it. It's very easy to use.

Just click on the layer you want to export and the plugin automatically create folders (drawable-xhdpi, drawable-hdpi...) and put them on.

I hope this can help you ;)

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