题外话:
1,android中的布局,其实可以优先考虑RelativeLayout,利用 android:layout_below这个属性来实现类似于线性布局的垂直布局,并且相较而言具有更大的灵活性
2,关于控件,甚至外围布局的android:layout_width、android:layout_height属性,不必排斥赋予具体的数值,不过为了更好的适配,考虑利用dip,sp为单位
3,margin,padding等可以为负值,(这样能产生帧布局类似的重叠效果?)
回归正题,android中实现圆角矩形:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<corners android:radius="5dp" />
<size
android:height="35dp"
android:width="120dp" />
<solid android:color="#FFFdFdFd" />
<stroke
android:width="1dp"
android:color="#FF959595" />
</shape>
在使用的时候,当作普通的图像文件即可,需要注意的是,为了显示出圆角矩形,使用的控件给出一定的margin属性;
<LinearLayout
android:layout_width="match_parent"
android:layout_height="110dp"
android:layout_below="@id/share_ll_sns"
android:layout_margin="5dp"
android:background="@drawable/share_by_sim_bg"
android:gravity="center_vertical"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/ll_share_wx"
android:layout_width="match_parent"
android:layout_height="55dp"
android:gravity="center_vertical" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:layout_weight="3"
android:focusable="false"
android:text="分享至微信"
android:textColor="#FF000000" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="2"
android:src="@drawable/right_forward" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="#000" />
<LinearLayout
android:id="@+id/ll_share_wx"
android:layout_width="match_parent"
android:layout_height="55dp"
android:gravity="center_vertical" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:layout_weight="3"
android:focusable="false"
android:text="分享至短信"
android:textColor="#FF000000" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="2"
android:src="@drawable/right_forward" />
</LinearLayout>
</LinearLayout>