[mobilesafe] 01_设置密码界面

Android 4.0

设置密码界面

1、系统的样式style:\sdk\platforms\android-16\data\res\values\styles.xml--Button的默认样式
<resources>  
    <style name="Widget.Button">
        <item name="android:background">@android:drawable/btn_default</item>
        <item name="android:focusable">true</item>
        <item name="android:clickable">true</item>
        <item name="android:textAppearance">?android:attr/textAppearanceSmallInverse</item>
        <item name="android:textColor">@android:color/primary_text_light</item>
        <item name="android:gravity">center_vertical|center_horizontal</item>
    </style>
</resources>
2、Button样式是一个状态选择器:sdk\platforms\android-16\data\res\drawable\btn_default.xml
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_window_focused="false" android:state_enabled="true"
        android:drawable="@drawable/btn_default_normal" />
    <item android:state_window_focused="false" android:state_enabled="false"
        android:drawable="@drawable/btn_default_normal_disable" />
    <item android:state_pressed="true" 
        android:drawable="@drawable/btn_default_pressed" />
    <item android:state_focused="true" android:state_enabled="true"
        android:drawable="@drawable/btn_default_selected" />
    <item android:state_enabled="true"
        android:drawable="@drawable/btn_default_normal" />
    <item android:state_focused="true"
        android:drawable="@drawable/btn_default_normal_disable_focused" />
    <item
         android:drawable="@drawable/btn_default_normal_disable" />
</selector>
3、被选中的状态图标,一个9-patch图片:btn_default_selected.9.png

背景为黑色,且和上面有一定的距离,这是由于系统定义AlertDialog默认是这个
1) 对话框背景为黑色-且alertdialog上的view和alertdialog默认的背景颜色有一定的距离,如上图
setView(View view, int viewSpacingLeft, int viewSpacingTop, int viewSpacingRight,int viewSpacingBottom)  
2)按钮太丑,自定义点击效果
a) \res\drawable\selector_btn_green.xml

<?xml version="1.0" encoding="utf-8"?>
<!-- 5、手机防盗-弹出对话框按钮的状态选择器 -->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@drawable/btn_green_pressed" android:state_enabled="true" android:state_focused="true"/>
    <item android:drawable="@drawable/btn_green_pressed" android:state_enabled="true" android:state_pressed="true"/>
    <item android:drawable="@drawable/btn_green_normal"/>
</selector>  
b) \resdrawable-hdpi\btn_green_pressed.9.png和btn_green_normal.9.png
 
3)按钮文字距离边框太近
<Button
    android:id="@+id/bt_home_ok"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/selector_btn_green" //自定义状态选择器
    android:paddingBottom="5dip"
    android:paddingLeft="10dip"
    android:paddingRight="10dip"
    android:paddingTop="5dip"
    android:text="确定" />