To bypass rectangles as a background in any layout, you can use 9 patch PNG images or use the shape class to create custom drawings.
Just check out my sample code below, it may come in handy.
main.xml in the layout folder
<?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="fill_parent" android:orientation="vertical" > <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:layout_margin="20dip" android:orientation="vertical" android:background="@drawable/bg"> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Testing white rectangle" android:textColor="#f00" android:padding="10dip" android:textSize="25dip" /> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Testing white rectangle" android:textColor="#0f0" android:padding="10dip" android:textSize="25dip" /> </LinearLayout> </LinearLayout>
bg.xml in the selected folder
<?xml version="1.0" encoding="UTF-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <solid android:color="#fff"/> <corners android:bottomLeftRadius="7dip" android:topRightRadius="7dip" android:topLeftRadius="7dip" android:bottomRightRadius="7dip" /> </shape>
Java file
public class WhiteRectangle extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); } }
Output

source share