This is just a portion of the background image. I have a gridlayout with 4 rows and 3 columns. These buttons in the layout (included just 3 for now) need to superimpose a background image which has a numeric keypad. I need to put the buttons exactly to fit these parts of image which have the numbers and will then make it transparent, so clicking on a number corresponds to clicking the actual button. Tried several methods but to no avail. I am not able to exactly fit them. Increasing the spacing between might help but just not able to get at it. Could someone please help? Thanks!
It will be exceedingly difficult to make sure the buttons fit the superimposed image exactly on devices with different screen sizes and different pixel densities. You are much better off having the user tap on the button itself. Use white for the text color and make a single rounded rectangle to use as the background of each button.
In src/main/res/drawable/orange_round_rect.xml:
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="4dp" />
<solid android:color="#color/orange_button" />
</shape>
Anything that isn't the button can be added elsewhere, e.g. as a background of the GridLayout.
Related
I need to create a seekbar that has custom background and custom thumb image. The problem is that background is kind of complex and i can't really create nice 9patch out of it.
Seekbar should have 3 values (0,1,2) and each value is represented by an image. Thumb should be centered around image of current value. Picture shows the seekbar with value "1" selected:
Problems I had were:
to create a 9patch from background and keep edge and central image from moving / scaling.
create a thumb that will always be in right scale compared to images representing different values.
How can I do this?
Edit
In short: I'm having troubles to make sure seekbar fills entire width of the screen (regardless of screen size), but again to make sure "ring" (thumb) will always fit perfectly around each "value" image.
I am not quite sure I understand your problem, but you can create a bitmap xml to avoid resizing on your background pictures:
<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="#drawable/mydrawable"
android:tileMode="disabled"
android:gravity="top" >
</bitmap>
If you are having troubles with arranging the items/pictures, you can always play with a relative layout's diferent params.
I want to create a bookshelf that tiles horizontally and vertically. I have three images, ShelfLeft, ShelfMid, and ShelfRight. ShelfLeft starts each row/shelf, followed by X ShelfMids across the screen, capped off by ShelfRight at the end of each row.
There will be a default of 5 rows, and if more are needed, they shall be able to be added dynamically.
What is the best way to go about doing this?
Thanks.
I'd use a TableLayout. Use a cell for each of the "ends", and then another single cell for the tiled background.
To make a background repeat, create res/drawable/my_background.xml:
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="#drawable/back"
android:tileMode="repeat" />
Then reference this as the background in your layout by specifying `android:background="#drawable/my_background".
(Source: http://androidblogger.blogspot.com/2009/01/how-to-have-tiled-background-cont.html)
Also worth noting: You might find the NinePatch class useful when creating your "ends".
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)
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
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.