Setting the button radius programmatically in android - android

I have a button say myButton. I want to set the top left corner radius of the button programmatically.
I'm looking for something like
myButton.setTopLeftCornerRadius(10);
I have looked for a method like 'setcornerradius' in eclipse but got nothing.

You can use shape drawable for this or rounded corner background Image.
For shape drawable detail please see this post.
How to set corner radiuses for the button in java code?
Cheers.

Button is type of View and all Views in Android occupy rectangular areas. However, you can set the background of the button to any image you like. Like a Shape Drawable with round corners.

Try this code for draw the rounded corners edittext:
How to create EditText with rounded corners?

Related

How to make cardview background as a shape of a rectangle with elongated botton right corner

I want a cardview to look like as in the image below. How to a create shape with rectangle with elongated botton right corner in the drawable and apply it as a background to a cardview? OR is there a better way to achieve this result?

How to flatten (opposed to rounding) button corners

I know how make the four edges of a button rounded using a drawable shape, but can one make the corners flat, such that the button will look like it has 8 edges (like an ocotogon)?
You can use
Yuor_button.setBackgroundDrawable(//something);
This "something" can be an image of octagon or you can try using Android Shape Drawables Tutorial

Android create item in GridView with round corners and ImageView

I have a GriView in which every element is a card with rounded corners. At the top of it there's an ImageView loaded from the net. I would like to fit the image inside the card so that it will have the top corners rounded. I've tryied with layer-list background, but no result.
Is there anyone who can give me some hints?
Thanks in advance
I found a solution: just put a rounded imageview (rectangle with rounded corners) behind the opaque relative layout (with same amount of rounded corners only in the bottom) and then set a negative bottom margin in the imageview, so that it will be covered for nearly 5 px by the relative layout
you can use this lib
and set this parameter for it:
<com.joooonho.SelectableRoundedImageView
...
app:sriv_left_top_corner_radius="16dip"
app:sriv_right_top_corner_radius="16dip"
app:sriv_left_bottom_corner_radius="0dip"
app:sriv_right_bottom_corner_radius="0dip"
...
app:sriv_oval="false" />

Setting border color of some part of View

I want to paint Fragment View border's left but not whole border. I want to use left buttons as tabs. When clicked on one of them, I want to paint whole borders of button but right and paint view's left corner except button's right side which clicked on.
Is there any way to do this?
You can create a nine-patch image that has only the left boarder and apply it as the background of the fragment.
more information on how to create a nine-patch image could be found here:
http://radleymarx.com/blog/simple-guide-to-9-patch/
and here:
http://android9patch.blogspot.co.il/

Gradient for border in Android

I have some text in a relative layout.I know that we can draw a border with curves using stroke and corner in a separate xml.
Is there a way to apply gradient effect for the border constructed with the stroke? or is there any other way to draw a gradient border?
Thanks in advance.
I don't know of a way to do that trivially, but it seems like you could define two shape drawables and combine with a layer drawable. The bottom one would be a rounded corner rectangle with a gradient, the top one would be a slightly smaller rounded corner rectangle of whatever you wanted the interior color to be. The effect should be something like a stroke gradient, although I haven't tried it.

Categories

Resources