How to change a button's shape using xml or using java?
Asked Answered
B

2

7

I want to make a custom button with shape, how to do this?

Better answered 13/7, 2011 at 5:59 Comment(2)
"want make custom button with shape" is not a understandable description .Elaborate the problem.Parboil
See this: custom button style and theme in androidFarnese
S
19

This is the sample button which is of oval shape.. The gradient says the start n end color along with the angle. corners for the oval shape..Try this.. Mention the name of this xml in button background android:background="@drawable/sample".Save the xml in drawable.

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <gradient
        android:startColor="#302226"
        android:endColor="#6D7B8D"
        android:angle="45"/>
    <padding android:left="6dp"
        android:top="6dp"
        android:right="6dp"
        android:bottom="6dp" />
    <corners android:radius="30dp" />

</shape>

Also check this link for custom button.

Sunflower answered 13/7, 2011 at 6:5 Comment(1)
@Better what if I want it to look like an arrow ? is there a way to do that?Transubstantiation
E
0

Another way to find button in different shapes

Use imagebutton in xml as

      <ImageButton
             android:id="@+id/imageButton1"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:src="@drawable/shape_oval" />

Shape_oval is an image which we can take from google serching or drawing ourself in paint or photoshop.

Egotist answered 12/12, 2012 at 9:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.