android:digits
在Android开发中,经常要设置EditText为密码显示,但是通常要求密码只能是 **字母和数字 . _ **的组合,此时就可以用该属性进行过滤
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:digits="0123456789abcdefghigklmnopqrstuvwxyzQWERTYUIOPASDFGHJKLZXCVBNM._"
/>
android:duplicateParentState="true"
该属性可以让子View跟随其Parent的状态。常见的使用场景是某个按钮特别小,为了设置点击事件,给其包裹一层Parent布局,将点击事件写到Parent上,如果希望被包裹按钮的点击效果对应的Selector继续生效的话,就可以使用它了,来个有说服力的测试案例。
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<RelativeLayout
android:id="@+id/content" android:layout_width="300dp"
android:layout_height="300dp"
android:layout_centerInParent="true"
android:background="@drawable/selector_back">
<Button android:layout_width="50dp"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:background="@drawable/selector"
android:duplicateParentState="true" />
</RelativeLayout>
</RelativeLayout>
Toolbar属性
<style name="ToolbarBaseStyle">
<item name="android:background">?attr/colorPrimary</item>
<item name="android:textColorPrimary">?android:attr/textColorPrimary</item>
<item name="titleTextAppearance">@style/ActionBarTitle</item>
<item name="navigationIcon">@drawable/ic_back</item>
<item name="logo">@drawable/ic_title_divider</item>
<item name="titleMarginStart">16dp</item><!--标题距离Logo距离-->
<item name="android:fitsSystemWindows">true</item><!--沉浸式必备-->
</style>
<style name="ActionBarTitle" parent="TextAppearance.Widget.AppCompat.Toolbar.Title">
<item name="android:textSize">16sp</item>
<item name="android:textColor">@color/white</item>
</style>
<!-- App theme here. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/primary</item><!---沉浸式颜色->
<item name="colorPrimaryDark">@color/primary</item>
<item name="colorAccent">@color/primary</item>
<item name="android:windowBackground">@color/grey6</item>
<item name="toolbarNavigationButtonStyle">@style/ToolbarNavigationButtonStyle</item>
<item name="actionMenuTextAppearance">@style/ToolbarMenuTextSize</item>
<item name="toolbarStyle">@style/ToolbarStyle</item><item name="actionButtonStyle">@style/MyActionButtonStyle</item>
</style>
<style name="ToolbarNavigationButtonStyle" parent="@style/Widget.AppCompat.Toolbar.Button.Navigation">
<item name="android:minWidth">56dp</item><!--返回按钮最小宽度-->
</style>
<style name="MyActionButtonStyle">
<item name="android:background">?attr/actionBarItemBackground</item>
<item name="android:scaleType">center</item>
<item name="android:gravity">center</item>
<item name="android:maxLines">2</item>
<item name="android:minWidth">0dp</item>
<item name="android:padding">15dp</item>
</style>
<style name="ToolbarStyle" parent="@style/Widget.AppCompat.Toolbar">
<item name="titleMargin">0dp</item>
<item name="contentInsetStart">0dp</item>
<item name="contentInsetStartWithNavigation">0dp</item>
<item name="titleTextAppearance">@style/ActionBarTitle</item>
</style>
<!-- toolbar菜单文字尺寸 -->
<style name="ToolbarMenuTextSize" parent="@style/TextAppearance.AppCompat.Menu">
<item name="android:textSize">14sp</item>
</style>