1.TextView中可写在Style中的一些常用属性
<item name="android:editable">false</item> //设置是否可编辑
<item name="android:inputType">numberDecimal/text/textPassword/textMultiLine</item> //设置输入字符类型数字、文本、密码、多行显示
<item name="android:digits">abcdefghijklmnopqrstuvwxyz_</item> //设置允许输入指定字符
<item name="android:cursorVisible">false</item> //设定光标为显示/隐藏,默认显示
<item name="android:textCursorDrawable">@drawable/edit_cursor_color</item> //设置光标的颜色
<item name="android:lines">3</item> //设置文本的行数3行
<item name="android:maxLength">10</item> //限制显示的文本长度
<item name="android:singleLine">true</item> //设置单行显示
<item name="android:textColor">@color/bg_gray</item> //设置文本颜色
<item name="android:textSize">12sp</item> //设置输入字符大小
<item name="android:textStyle">italic|bold</item> //设置字形,可以设置一个或多个,用“|”隔开
<item name="android:paddingLeft">5dp</item> //文字离文字框左边的距离
<item name="android:drawableLeft">@drawable/show1</item> //图片在文字左边
<item name="android:drawableTop">numberDecimal/text/</item> //图片在文字上边
2.一些自定义表格
<style name="TableRowHeadStyle" note="TableRow表格头样式">
<item name="android:background">@drawable/bg_round_white</item>
<item name="android:orientation">horizontal</item>
<item name="android:baselineAligned">true</item>
</style>
<style name="TextViewDateStyle" note="日期控件样式">
<item name="android:layout_width">50dp</item>
<item name="android:layout_height">25dp</item>
<item name="android:layout_marginLeft">10dp</item>
<item name="android:textSize">@dimen/common_text_size</item>
<item name="android:textColor">@color/config_color_edittext_textcolor</item>
<item name="android:gravity">center_vertical</item>
<item name="android:background">@drawable/config_bg_edittext</item>
<item name="android:paddingLeft">3dp</item>
<item name="android:longClickable">false</item>
</style>
<!-- EditText的文字样式 -->
<style name="EditTextStyle" note="通用编辑框样式">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">@dimen/common_edit_text_height</item>
<item name="android:inputType">text</item>
<item name="android:textSize">@dimen/common_text_size</item>
<item name="android:textColor">@color/config_color_edittext_textcolor</item>
<item name="android:gravity">center_vertical</item>
<item name="android:background">@drawable/config_bg_edittext</item>
<item name="android:paddingLeft">5dp</item>
<item name="android:longClickable">false</item>
<item name="android:textCursorDrawable">@drawable/edit_cursor_color</item>
</style>
<style name="EditTextReadOnlyLongFixedDimen" note="通用不可编辑框样式">
<item name="android:layout_width">130dp</item>
<item name="android:layout_height">@dimen/common_edit_text_height</item>
<item name="android:textColor">@color/common_text_disable</item>
<item name="android:textSize">@dimen/common_text_size</item>
<item name="android:paddingLeft">5dp</item>
<item name="android:longClickable">false</item>
<item name="android:editable">false</item>
<item name="android:gravity">center_vertical</item>
<item name="android:background">@drawable/editext_disabled_background</item>
</style>
<style name="EditTextLongFixedDimen" parent="EditTextStyle">
<item name="android:layout_width">130dp</item>
</style>
<style name="SystemSettingWordLimit" parent="EditTextStyle">
<item name="android:maxLength">15</item>
<item name="android:digits">.0123456789</item>
</style>
style的background属性具体内容为:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<stroke
android:width="1dp"
android:color="@color/common_green_light" />
<corners
android:radius="0dp" />
<solid android:color="#FFFFFF"/>
</shape>
形状如下:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/common_edittext_backkground"></solid>
<stroke
android:width="0.2dp"
android:color="@color/item_divider_line_color">
</stroke>
</shape>
形状如下:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<solid android:color="@color/green"/>
<corners android:topLeftRadius="8dp"
/>
</shape>
形状如下:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="false"
android:drawable="@drawable/config_color_edittext_disable"/>
<item android:state_pressed="true"
android:drawable="@drawable/config_color_edittext_touch" />
<item android:state_focused="true"
android:drawable="@drawable/config_color_edittext_touch" />
<item android:drawable="@drawable/editext_background" />
</selector>
形状可选择: