I'm not sure what goes on under the hood in Muzei.
I have assets for
mdpi (48x48)
hdpi (72x72)
xhdpi (96x96)
xxhdpi (144x144)
xxxhdpi (192x192)
nodpi (512x512)
I've followed the example source's folder/asset structure to the T, but, when Muzei loads my source, it fills the entire selector circle with the icon instead of centring it nicely in the middle with ample padding like the defaults (see below).
My Manifest is basically:
<application android:allowBackup="true" android:label="#string/app_name" >
<service
android:name=".UnsplashForMuzeiRemoteArtSource"
android:description="#string/source_description"
android:icon="#drawable/ic_launcher"
android:label="#string/source_name" >
...
</service>
</application>
It looks like Muzei doesn't do anything to the icon, just displays it without scaling or padding.
What I did to fix it is just added padding to the PNG (to my base SVG and re-converted it).
Related
I am new android user and using Android Studio 1.3. I want to create simple splash screen, for that,i create different drawable folders where i store splash screen background images. I copy all ic_launcher from respective mipmap folders and paste them in respective drawable folders. and change icon path in manifest also.as,
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme">
to,
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
but this is giving me error that,
Error:(14, 24) No resource found that matches the given name (at 'icon' with value '#mipmap/ic_launcher').
My question is,
Does we always need to store app icons in mipmap folders only? why?
When to use mipmap and drawable?
Using mipmaps for your launcher icon is described as best practice by the Android team. The advantage you get is that you can keep resources in the mipmap folders for all device densities and then strip out other resources from the drawable folders that are not relevant to the specific users device density.
For example a user has a device that is classified as xxhdpi. The drawable resources in your apk for all other densities, such as xxxhdpi, are not required and can be stripped out.
reference
The mipmap folders are for placing your app/launcher icons (which are shown on the homescreen) in only.
Any other drawable assets you use should be placed in the relevant drawable folders as before.
According to this Google blogpost and Android Dev's Recommended:
It’s best practice to place your app icons in mipmap- folders (not the drawable- folders) because they are used at resolutions different from the device’s current density.
i'm building my first app and i wanna make the app to be optimized for all screen resolutions.
So, i'll tell you what i think i should do -in order to make my app work- with what i've found so far, but i don't feel like i've understand that despite some relevant posts that i read.
I've made the background image at 480 x 800 pixels for high resolution (hdp), 320x480 for medium res (mdp), 240x320 for low res (ldp) and 600x1024 for xhdp(??).
Then, if i put each one on the right folder in the "res" directory...for example "drawable-hdpi" for high resolution etc...will it work?
Are these the right dimensions?
Here is my Manifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.etking.winningnumbersgenerator"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="19" />
<supports-screens
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:anyDensity="true" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.etking.winningnumbersgenerator.MainActivity"
android:label="#string/app_name"
android:screenOrientation="portrait"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
(Please notice the supports-screens)
And my activity_main.xml:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.etking.winningnumbersgenerator.MainActivity"
tools:ignore="MergeRootFrame" />
Is it correct the way i described above?
What do i need to do? Please help me with my first app!!!
P.S: If you need something else from the code,ask for it
EDIT: (Please read only below)
I have read Android "Supporting Multiple Screens" but maybe was something i didn't get.
I created a background image for each drawable folder: 240x320 in drawable-ldpi folder, 320x480 in drawable-mdpi, 480x800 in drawable-hdpi, 640x960 in drawable-xhdpi and 1200x1920 in drawable-xxhpdi.
The app displays well on the below screens (using emulator):
768x1280 xhdpi - 4.7'', |
480x800 hdpi - 4.0'' , |
240x432 ldpi - 3.4'' , |
1080x1920 xxhdpi - 4.95'' (Nexus 5) and
320x480 mdpi - 3.2''
It does not look well on:
480x800 mdpi - 5.1'' and 1200x1920 xhdpi - 7'' as it has too much space in the middle down to the bottom of the image.
and also on
240x320 ldpi - 2.7'' the button nearest to the bottom is almost cropped as it is appeared down on the bottom of the screen.
Note that the background image displays well.
I've put layout_width="230dp" and layout_height="50dp" for the button.
Plase help me on this!
P.S: I'm not allowed to post images so you could understand better :(
I suggest you read the Developer Guide on developing your app to support multiple Screen Sizes. It will help you very well not just focusing on screen size, but also on screen DPI (Density per Inch)
When I install and run application I see on the desktop large HDPI icon, but when activity starts, I see small MDPI icon. The icons have some marks to differentiate them, so I am sure what icons I see.
Layout:
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/icon"
/>
AndroidManifest.xml
<application
android:icon="#drawable/icon"
android:label="#string/app_name" >
...
Icons:
/drawable-mdpi/icon.png -> 48x48 px
/drawable-hdpi/icon.png -> 72x72 px
Display metrics:
DisplayMetrics{density=1.0, width=1280, height=752, scaledDensity=1.0, xdpi=160.15764, ydpi=160.0}
So, why does it take HDPI to display on desktop? And MDPI for my screens?
What is the physical size of your devices screen? I have a feeling your application is simply running in a screen compatibility mode. Otherwise, perhaps your packages resources are screwed up in some way. Normally cleaning the project in Eclipse will resolve that. If its the compatibility mode check this page for more information: http://developer.android.com/guide/practices/screen-compat-mode.html
I am looking at these Android instructions: http://developer.android.com/guide/practices/ui_guidelines/icon_design_launcher.html#size
and I made the 4 image sizes, but how do I specify them in the Android Manifest file? And where do I place the images within the code base?
So far I have this
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/CustomTheme" >
But not sure how to specify the specific sizes of the launches icons and when they need to show up.
Thanks!
You don't need to write anything on manifest file.
You need to put images on related drawable folders like:
res\drawable-hdpi\ic_launcher.png
res\drawable-mdpi\ic_launcher.png
res\drawable-ldpi\ic_launcher.png
res\drawable-xhdpi\ic_launcher.png
You do not have to specify it in Manifest File, place them in drawable-hdpi, drawable-mdpi and drawable-ldpi folders depending upon the resolution, you can create one more folder drawable-xhdpi to support new High density screens like those like Google Nexus
You have to place images in folder res/drawable-hdpi, res/drawable-ldpi, res/drawable-mdpi and
change the name "icon" to your_name in the below code in Android Manifest.
<application android:icon="#drawable/icon" android:label="#string/app_name">
Where do I put my icons in my android file structure, and how do I reference them in the manifest xml?
Thanks
You put them in your drawables folders under res.
There are three "types" of drawables, hi-res, med-res and low-res respectively.
Each gets their own folder:
drawable-hdpi
drawable-mdpi
drawable-ldpi
You can reference them in your code directly by using
R.drawable.(icon name)
If you want to use them in your XML files, use this instead:
#drawable/(icon name)
As long as your drawables have the same name in all the folders, Android will pick the right one to show depending on the DPI of your device's screen.
More info about drawables here: http://developer.android.com/guide/topics/resources/drawable-resource.html
For those reading back later, the question was about the launcher icons.
Their sizes are as follows:
ldpi: 36x36 px
mdpi: 48x48 px
hdpi: 64x64 px
xhdpi: 96x96 px
You can find more about the launcher icons here: http://developer.android.com/guide/practices/ui_guidelines/icon_design_launcher.html#size
The article also gives some do's and don'ts about launcher icons. Might be worth a look.
I assume you mean a main icon for your application? If not please disregard this answer.
Under res create a drawable folder and place your icon there.
In the androidmanifest.xml you'll need to add the following code
<application android:icon="#drawable/logo" android:label="#string/app_name">
You can exchange the logo to fit your icon filename.
In the relevent drawable folder e.g. res/drawable-hdpi