Create button with rounded corner
Description
The following code shows how to create button with rounded corner.
Example
res/drawable/button_rounded_background.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#AAAAAA"/>
<corners android:radius="15dp"/>
</shape>
Layout xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<Button android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World, MainActivity!"
android:textColor="#000000"
android:padding="10dp"
android:background="@drawable/button_rounded_background"/>
</LinearLayout>
Java code
import android.app.Activity;
import android.os.Bundle;
//w w w . java 2 s . c om
public class MainActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}