本文实例讲述了Android编程实现圆角边框布局效果的方法。分享给大家供大家参考,具体如下:

这里用的是TableLayout布局的。先看效果图

下面看下布局文件
<?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:background="#FFFFFF"
android:orientation="vertical" >
<!-- 表格布局 -->
<TableLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="10dip" >
<!-- 表格布局:第一行 -->
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/shape_top_corner_no_bottom_line"
android:padding="10dip" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginRight="10dip"
android:text="姓名:" >
</TextView>
<EditText
android:id="@+id/bankingYourNameEditText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:background="@null"
android:singleLine="true" >
</EditText>
</TableRow>
<!-- 表格布局:第二行 -->
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/shape_no_corner_without_bottom"
android:padding="10dip" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginRight="10dip"
android:text="联系电话:" >
</TextView>
<EditText
android:id="@+id/bankingContactTelEditText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:background="@null"
android:inputType="phone"
android:singleLine="true" >
</EditText>
</TableRow>
<!-- 表格布局:第三行 -->
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/shape_bottom_corner_no_top_line"
android:padding="10dip" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginRight="10dip"
android:text="联系电话:" >
</TextView>
<EditText
android:id="@+id/bankingContactTelEditText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:background="@null"
android:inputType="phone"
android:singleLine="true" >
</EditText>
</TableRow>
</TableLayout>
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Button" />
</LinearLayout>