先看效果:
一、布局文件(button.xml)
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center">
<Button
android:id="@+id/btn_shopcare"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_gravity="center"
android:background="@drawable/bg_button_left"
android:text="加入购物车"
android:textColor="@color/white"
android:textSize="12sp" />