dimension of image background for android actionbar - android

I want to design an image background for my android app's action bar, but have no idea what dimension I have make so that it fits in different screen resolution.
Do I need to design the same image background separately for each screen densities?
I want to design it in photoshope is that a good option?
any idea Please !

I would suggest you use a gradient which you can store in the drawable folder
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<gradient
android:startColor="#00445a"
android:endColor="#00699a"
android:angle="90"
android:type="linear"
/>
</shape>
This will prevent all the trouble of trying to adapt to screen sizes.

Create 3 .png versions of the image, for hdpi/xhdpi/xxhdpi densities.

Related

Make gradient look the same on different screens

I have defined gradient drawable for my app's navigation drawer's header,
side_nav_bar.xml:
<gradient
android:centerColor="#color/ColorTwoBackground"
android:endColor="#color/ColorTwoForeground"
android:gradientRadius="400"
android:startColor="#color/ColorTwoBackground"
android:type="radial" >
</gradient>
However, it looks as intended only on some devices. On other devices it looks bad.
As you can see in the last image logo loses its contrast...
I want to change it to appear identical or even closely the same on different screens. Probably gradientRadius value does the biggest impact but I have tried other values and "400" seemed to be optimal. Maybe it is possible to determine it programmatically?

How to use Nine-patch images correctly

I want to create some kind of row image that looks like that
but I want it to scale with the screen size and density. So reading this http://developer.android.com/guide/developing/tools/draw9patch.html and this http://developer.android.com/guide/topics/graphics/2d-graphics.html#nine-patch I startet creating a Nine-patch image.
But when I import it and use it in my android project it looks like that
As you can see the little black line that was drawn with the draw 9 patch tool is still visible. Why?
Here is the 9.png image
Are you using the draw9patch tool that comes with the sdk? it is quite handy.
Anyway:
It is vital that every pixel except the black ones are completely
transparent.
The black pixels should be at the absolute top/bottom/left/right of
the image.
The image should be named filename.9.png.
I have found the best and the simplest answer to make 9-patch image.
This is best link to create 9-patch image for all the resolutions - XHDPI, HDPI, MDPI, LDPI in just one click.
Let me know if you have any queries, and do upvote it, if it was helpful to you.
If you need an image which consists of a border with rounded corners, I don't have to create a 9-patch.
All you need is an XML like this stored in the res/drawable directory
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<corners android:radius="3.0dp" />
<stroke
android:width="2dp"
android:color="#color/green" />
</shape>
Read more about drawable resources

Android how to do intricate backgrounds and borders

I want to do intricate borders in my android popups like I see on the ipad.
example:
What I see here is a thick gradient blue border with alpha transparency at the top. As well as a drop shadow extending further from the background.
In android I've tried using shape objects for doing semi intricate backgrounds. This is just a white border.
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid
android:color="#303030"/>
<stroke
android:width="1dip"
android:color="#ffffff"
/>
</shape>
but these are limited in that they can't accept images as variables here. I guess it would be awfully complex to do these kind of borders in Android. Like perhaps make a relativelayout or tables with the views having the pieces of the background. Kind of like an HTML layout.
Is there a better way to do complex and intricate borders in android? I'd like to make a polished skin kind of like how iOS has that one default that has a uniform aesthetic for iOS.
Yes it is complicated, but the good thing is you can reuse the layout you draw for all the components in your application, so you basically only have to do it once for each "style".
Here are a few pointers in which I've learned a lot about styling Android:
http://blog.donnfelker.com/2011/08/01/android-rounded-corners-with-a-beveldrop-shadow/
http://blog.stylingandroid.com/archives/378
Custom ImageView with drop shadow
Android: Using linear gradient as background looks banded
And here is the 9-patch image I use for drop-shadow (I think it's taken from one of the posts above)

Glossy gradient with android drawable xml

I'm trying to bring out a glossy xml drawable gradient as a background to a layout. I am already using the start color and end color boring linear gradient.
<item>
<shape>
<gradient
android:angle="90"
android:startColor="#242424"
android:endColor="#4e4e4e"
android:type="linear" />
</shape>
</item>
Is there any way to control its range of flow? Please some one help.
Edited:
Ok, I have done a little hack around method to get a nice glossy looking title bar,
Linear Layout (with a gradation - drawable background, specifying all
the start and end color values separately) Over this are the icons, (I
used Image buttons with transparent BG), and over this another Relative Layout (with may
be a drawable gradient or a fixed, grey color - for glossiness -
android:background="#20f0f0f0" ) Here 20 is defining the Alpha value.
P.S, This might not be a correct work around, but I'm quiet satisfied with this because switching themes according to clients needs is much faster when compared to 9 patch PNG files (hey, BTW this is just my opinion on it)
And this link is so informative on this,
you cant control its range of flow but instead you can use another property centerColor.
you should try the center color Property in gradient for glossy background.
i used this in my application .
<gradient
android:startColor="#FFF7F7F7"
android:centerColor="#FFCECFCE"
android:endColor="#FFBEBEBE"
android:angle="270"/>
hope this will work for you

match a nine-patch image with simple image

I want to put two images together (a nine-patch image with icon), So that icon size does not change.
I designed nine-patch image but i don't match these images together.
Is there anyone who can help me?
You can use the android layer list drawable. This allows to stack layers on top of each other. The first layer can hold the nine patch image and the second layer can hold the icon which wont be stretched.
This is how it would look like
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="#drawable/wp_tabbuttonstrip"/>
<item>
<bitmap android:src="#drawable/wp_dashboard_icon"
android:gravity="center"/>
</item>
</layer-list>
You will need to specify the size of the view, wrap content might not give the desired results.

Categories

Resources