定义application 的 theme
<application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity ... ... </activity> </application>
定义style
<resources xmlns:android="http://schemas.android.com/apk/res/android"> <style name="AppBaseTheme" parent="android:Theme.Light.NoTitleBar"></style> <style name="AppTheme" parent="AppBaseTheme"> <item name="android:textColor">@color/TextColor</item> <item name="android:windowAnimationStyle">@style/ActivitySiwtchAnimation</item> <item name="android:windowBackground">@color/white</item> <!-- Custom style on widgets --> <item name="android:editTextStyle">@style/AppTheme_EditTextStyle</item> <item name="android:buttonStyle">@style/AppTheme_ButtonStyle</item> </style> <style name="ActivitySiwtchAnimation"> <!-- Open Animation --> <item name="@android:activityOpenEnterAnimation">@animator/slide_left_enter</item> <item name="@android:activityOpenExitAnimation">@animator/slide_left_exit</item> <!-- Close Animation --> <item name="@android:activityCloseEnterAnimation">@animator/slide_right_enter</item> <item name="@android:activityCloseExitAnimation">@animator/slide_right_exit</item> </style> <!-- Custom Style EditText Widget --> <style name="AppTheme_EditTextStyle" parent="@android:style/Widget.EditText"> <item name="android:textColorHint">@color/HintTextColor</item> <item name="android:textColor">@color/TextColor</item> <item name="android:background">@drawable/date_edit_bg</item> <item name="android:padding">8dp</item> </style> <!-- Custom Style Button Widget --> <style name="AppTheme_ButtonStyle" parent="@android:style/Widget.Button"> <item name="android:textColor">@color/white</item> <item name="android:background">@color/BtnBackground</item> <item name="android:padding">10dp</item> <item name="android:textSize">20sp</item> </style> </resources>
动画
slide_left_enter
<?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android" > <translate android:duration="@android:integer/config_mediumAnimTime" android:fromXDelta="100%p" android:toXDelta="0" /> <!-- <alpha android:duration="@android:integer/config_mediumAnimTime" android:fromAlpha="0.5" android:toAlpha="1.0" /> --> </set>
slide_left_exit
<?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android" > <translate android:duration="@android:integer/config_mediumAnimTime" android:fromXDelta="0" android:toXDelta="-100%p" /> <!-- <alpha android:duration="@android:integer/config_mediumAnimTime" android:fromAlpha="1.0" android:toAlpha="1.0" /> --> </set>
slide_right_enter
<?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android" > <translate android:duration="@android:integer/config_mediumAnimTime" android:fromXDelta="-100%p" android:toXDelta="0" /> <!-- <alpha android:duration="@android:integer/config_mediumAnimTime" android:fromAlpha="1.0" android:toAlpha="1.0" /> --> </set>
slide_right_exit
<?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android" > <translate android:duration="@android:integer/config_mediumAnimTime" android:fromXDelta="0" android:toXDelta="100%p" /> <!-- <alpha android:duration="@android:integer/config_mediumAnimTime" android:fromAlpha="1.0" android:toAlpha="0.0" /> --> </set>