效果
代码解释
android:background="@drawable/shape_rectangle" 引用自己写的背景
android:textSize="30sp" 字体大小
android:gravity="center" 字体居正中
android:gravity="center_vertical" 字体居竖直方向的中
android:paddingLeft="50dp" 设置字体离左边距离
android:shape="rectangle" 边框为长方形
1.drawable 的代码(自己写的背景)
1.shape_color_rectangle
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#EE7942"/>
<stroke
android:color="#333333"
android:width="1dp"/>
</shape>
2.shape_rectangle
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#ffffff"/>
<stroke
android:color="#333333"
android:width="1dp"/>
</shape>
2.layout 代码
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="80dp"
android:orientation="horizontal">
<TextView
android:layout_width="0dp"
android