Android :: How To Add Padding To Gradient <shape> In Phone
Oct 25, 2009
I have a shape with a gradient that I'm using as a divider between ListView items. I've defined it as follows:
<?xml version="1.0" encoding="UTF-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:startColor="#ccd0d3"
android:centerColor="#b6babd"
android:endColor="#ccd0d3"
android:height="1px"
android:angle="0" />
</shape>
I would like to add 6 pixels of padding on either side of the gradient, so that it doesn't extend from edge to edge of the screen.
However, no matter where I put an android:left="6px" and android:right="6px", it doesn't seem to take effect. I can put it in the <shape> element, the <gradient> element, or in a separate <padding> child of <shape>, and it doesn't change anything.
How can I add padding on the left and right of my list divider?
View 2 Replies
Oct 27, 2010
I'm using xml file to define progress bar. I defined padding on background shape. But this setting will be sometimes displayed correctly, sometimes not. So If I start my application or Activity with progressbar inside, there will be correctly displayed progressbar with background and 'padded' progress. Then I close my application and start it again, and, progressbar is displayed without padded background, on next start will be displayed correctly and son on ... Could you please advice possible reasons for this?
xml file:..................
View 1 Replies
View Related
Aug 15, 2009
I am trying to set padding in shape declared in XML file. But whatever I set, nothing changes related to padding. If I modify any other properties, I see updated UI. But it doesn't work with padding. Could you please advice possible reasons for this?
I will provide below example of my shape.xml:
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<stroke android:width="1dp" android:color="#ffffff" android:dashWidth="2dp"/>
<solid android:color="@color/button_white_cover" />
<corners android:radius="11dp" />
<padding android:left="1dp" android:top="20dp"
android:right="20dp" android:bottom="2dp" />
</shape>
View 1 Replies
View Related
Jun 21, 2010
I want to have a elmenent with a 2 color border outline. I can do a single color outline using the element, but this only allows me to draw a single line. I tried using 2 elements within my but that didnt work either. Is there a way to either draw a shape within a shape or draw 2 lines around my shape (which has rounded corners btw).
View 3 Replies
View Related
Oct 19, 2010
In my android application i am using a image as background initially. Then on top of that i need to place small images and on top of the small images i would like to place a textview with some text on it.
I am using below code for that.With this am able to place the small images but the textview if i am trying to place it place in the next row and not over the image.
I also tried with adding the image as the background and then placing textview but at that case the padding and size of the image is not getting decreased.
Is there any way that i can have the images of size 60 by 60 and place a textview on top of these images.
Please share your valuable suggestions.
View 1 Replies
View Related
Jul 23, 2010
Is there a way to have 2 gradients in a drawable xml using either a <layer-list> or <shape> or some combination of them?
View 1 Replies
View Related
May 28, 2010
How can I get rid of the gradient at the top of my screen (the very top of the blue in the screenshot below... below the notification bar)?
View 1 Replies
View Related
Jun 5, 2009
I have a LinearLayout and I am setting a Background image. I am using a PNG24, and the image has a gradient in it. When I see the image on the computer the gradient is perfect, but when I see it on the emulator or on a real phone, some colors are lost and I see only like 10 colors, so I see lines and not a perfect gradient. Is the emulator 'compressing' the images? Should I make them in other format?
View 3 Replies
View Related
Dec 11, 2009
I'm trying to apply an Alpha gradient to a bitmap that I've created from a PNG. I want the image to be opaque at the top and fade to transparent at the bottom. I know this can be done be using getPixels and setPixels for Bitmap and iterating through each row of pixels in the Bitmap and setting the alpha values accordingly, but i was hoping there was a slightly neater way of doing this. I have been looking at the LinearGradient Class and using a Porter Duff transfer mode, but i don't seem to be having much luck with this. It seems that my source image is lost when i apply the Shader to the drawable. Anyone have any tips on how i might apply an alpha gradient to a bitmap?
View 2 Replies
View Related
Jul 26, 2010
In my app i have gradient as drawable which i am using as background and i want it to make it look as smooth as possible. After googling and trying by myself i came up with the following. On nexus one if you call only setDither(true) your gradient is still banding so you have to set PixelFormat like this Window.setFormat(PixelFormat.RGBA_8888). But on the other side G1 does not support RGBA_8888 so calling it make the gradient even uglier than before so Window.setFormat(PixelFormat.RGBA_8888) will not work well on devices that don't support it.What is the correct way smooth my gradient on all devices on which my app will run.
View 1 Replies
View Related
Sep 21, 2009
I have got another mysterious issue. So, I am setting a background image for LinearLayout. This image contains gradient. Don't know why, but after I launch application the image appears to consist of several parts that actually form "smooth transition" of gradient, and that's why it seems that background image is not a gradient.
View 1 Replies
View Related
Nov 2, 2009
I've been looking at some issues with the background of our application, particularly on high-density devices (240 dpi, 480x854). I managed to eliminate banding on existing devices (i.e. G1/G2, 160 dpi) by applying the android:dither="true" attribute to our nine-patch image, which is a 1x480px PNG with no noise added. Looks great. However, if I use the same image on a higher resolution device, the banding is pretty nasty looking. Same happens regardless of whether I use a shape+gradient, a noisy nine-patch PNG, or an android:dithered nine-patch PNG -- even if I create an 854px-tall image. Is the use of gradients going to become a problem on high screen density devices, purely because of the display colour depth, or is there any way to solve this?
View 5 Replies
View Related
Sep 23, 2010
I have a gray gradient drawable (png image in res/drawable). If I draw it on a white Canvas it looks banded (not smooth). If I put the gradient on white background in GIMP, and then draw this drawable on the Canvas, it looks great. What's the problem? I tested this on Nexus One. Calling setDither(true) on the drawable has no noticable effect.
View 2 Replies
View Related
Aug 10, 2010
In my Android application I've hidden the default title bar, introduced a TabView and added my own titlebar under that TabView's tabs. At the moment, I'm using the ?android:attr/windowTitleStyle style which makes my new titlebar look gray and gradient. It looks pretty good, but my screens are looking pretty grayscale. I'd like to spice things up a bit by making this titlebar a different color gradient.
What am I looking at here? Creating my own image and using it? The ?android:attr/windowTitleStyle style seems to expand depending on the height of your custom titlebar; so I'm not sure it's actually a single image.
I've attempted to throw a LinearLayout over it with a bit of translucency (ex: making the color #800000FF), but the gradient style I have behind this LinearLayout disappears.
Update:
Per my answer down below, I've figured out that I can create an XML file that defines a gradient and use that. It works fine inside a LinearLayout (titlebar_gradient) I have on my layout. However, it is not working on the outer-most LinearLayout (background_gradient). Could someone tell me why? As I understand it, the ListView should be transparent...
code:...............
View 1 Replies
View Related
Feb 15, 2010
I want to make a custom seek bar having color gradient as shown in the below image URL.
View 6 Replies
View Related
May 14, 2010
Given a closed Path object result is like this: http://www.tutorialguide.net/images/adobe_photoshop/0043/001.jpg. Although that is a rectangle I'm looking for something which works with any closed Path.
View 2 Replies
View Related
Oct 29, 2010
Seems my original post ("ugly pngs...") somehow disappeared :( nvm.
I have a problem with a png resource that has gradient fade-out alpha.
The png looks great in the emulator, but displays an artefact known as "color banding" (http://en.wikipedia.org/wiki/Colour_banding)
Has anyone surpassed this issue ?
My designer wants to trop a shadow behind his icons, and that's where the bands appear.
What are my options ?
View 13 Replies
View Related
Apr 21, 2010
How would I extend TextView to allow the drawing of text with a gradient effect?
View 2 Replies
View Related
Aug 10, 2010
I have a horizontal LinearLayout. This LinearLayout has a checkbox next to another LinearLayout. The layout width/height of the checkbox is wrap_content, whereas the inner LinearLayout is fill_parent/wrap_content. The layout_weight of the inner LinearLayout is set to 1.
I've tried to add some android:padding around the checkbox to give some space around it, but no padding is given. I've also tried android:paddingLeft/Right/etc. How do I get some padding around my checkbox?
Note: I have an inner LinearLayout because I will be adding more TextViews
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="?android:attr/listPreferredItemHeight">
<CheckBox
android:id="@+id/mycheck"
android:text=""
android:layout_width="30dip"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:focusable="false"
android:background="@drawable/checkbox_background"
android:button="@drawable/checkbox"
/>
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_weight="1"
android:layout_height="wrap_content">
<TextView
android:id="@+id/mytext"
android:layout_width="fill_parent"
android:layout_weight="1"
android:gravity="center_vertical"
android:layout_height="wrap_content"
android:lines="1"
android:textColor="@color/white"
android:textSize="10sp"
android:textStyle="italic"/>
</LinearLayout>
</LinearLayout>
View 1 Replies
View Related
Nov 11, 2010
Is there a way to draw a circular gradient mask on a bitmap in Android? Trying to produce something similar to a foggy window. Click the window and a transparent circle shows up revealing whats behind the window. Prefferably using a gradient so the center of the circle is completely transparent and the further out from the center the less transparent. Is this possible?
View 1 Replies
View Related
May 31, 2010
I have a list where i basically need a hierarchy of items. Any children of an item would be padded slightly, as to easily distinguish their parent item. How could this be achieved? Note that i could, if needed, make each parent show no children, and then when the parent is clicked, a new list containing all of it's children is loaded. This however requires more clicking to display information than i would prefer. Also, the items themselves will contain graphics and whatnot (to show a drag'n'drop button, etc), so it would be best if it visually appeared as if the item itself had a margin, rather than the contents of the item being padded.
View 1 Replies
View Related
Apr 26, 2010
I have a linear layout which has a background image (a 9 patched png file). How can I add padding to left and right so that the background image does not take up the whole width? I have tried 'android:paddingLeft' and 'android:paddingRight', but that does not change anything.
CODE:.....
The whole background still stretches the whole screen width.
View 1 Replies
View Related
Sep 28, 2010
I have the following layout. This defines a row in my ListView. I noticed that the text is not centered in the row. There seems to be extra bottom padding. How can I make the text appear in the center, vertically, so there is no padding? code...
View 1 Replies
View Related
Oct 18, 2010
what is the difference between padding and margin?
i want to draw a view exactly at 200 dip from the top of the screen(0,0). there are some layout in the middle.
how do i draw a view exactly at 200 dip from the top?
View 4 Replies
View Related
Apr 2, 2010
I'm following an example where the author hard coded a paddingTop to 370px. How do I make that paddingTop dynamic? When I run this in 2 AVDs with HVGA and WVGA80 I get the frame floating at different heights. I'd like to say something like paddingTop=80%, but that doesn't work.
View 1 Replies
View Related
Sep 12, 2010
I have a 3*3 TableLayout that contains buttons. But I cannot seem to remove the spacing between the buttons in the Table.Setting pading to zero for the buttons has no effect. Setting padding and layout_margin to zero for the TableRow has no effect. Setting layout_margin for the TableLayout has no effect.Any idea on how I can alter/remove/reduce the spacing between the cells?
View 4 Replies
View Related
Mar 2, 2009
I am trying to create a NinePatchDrawable programmatically, but there is no documentation on the constructor's argruments (Bitmap bitmap, byte[] chunk, Rect padding, String srcName). Does anyone know what chunk and padding are... and how to specify them?
View 7 Replies
View Related
Oct 30, 2009
Difference between View margin and padding , mPadding and mUserPadding?
View 2 Replies
View Related
Oct 16, 2009
I'm doing the HelloViews Gridview tutorial and I ran into this problem.
http://grab.by/9Vn
I have a padding that I can't find where is it coming from.
XML is the following: <?xml version="1.0" encoding="utf-8"?> <GridView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/gridview" android:layout_width="fill_parent" android:layout_height="fill_parent" android:numColumns="2" android:verticalSpacing="0px" android:horizontalSpacing="0px" android:stretchMode="columnWidth"android:gravity="center" android:layout_margin="0dp" />
and in my adapter:
I can't seem to find the place where I can get rid of that padding (or margin). Pictures are 160px x 160px.
View 3 Replies
View Related
Jan 27, 2010
I am creating a button programmatically. It is rounded and has a gradient background, and works fine and looks nice, but I couldn't do two things I wanted:
Set a 1 pixel stroke with a given color. I tried getPaint().setStroke(), but couldn't figure how to set the stroke color. How should I do it?
Align the gradient to the bottom of the button, no matter what height it has. Is this possible?
For reference, this is the code I'm using:
CODE:...................
View 1 Replies
View Related