|
1 | 1 | # HeaderLayout
|
| 2 | +欢迎大家使用。<br> |
| 3 | +此自定义控件为头部标题栏控件<br><br> |
| 4 | +<B>主要提供内容:</B> |
| 5 | + |
| 6 | +左边按钮: |
| 7 | +默认支持icon和文字两种方式(只能选一个,左边按钮默认只有一个) |
| 8 | + |
| 9 | +标题文字: |
| 10 | +支持居左和居中显示 |
| 11 | + |
| 12 | +右边按钮: |
| 13 | +最多支持四个显示(2个文字、2个按钮 ) |
| 14 | + |
| 15 | +自定义效果: |
| 16 | +控件基于RelativeLayout,所以可以自由添加需要的内容 |
| 17 | + |
| 18 | + |
| 19 | +<B>调用步骤:</B><br><br> |
| 20 | +**1、可配置的所有内容** |
| 21 | + |
| 22 | + <?xml version="1.0" encoding="utf-8"?> |
| 23 | +<resources> |
| 24 | + <item name="hl_status_padding_iv" type="id"/> |
| 25 | + <item name="hl_navigation_view" type="id"/> |
| 26 | + |
| 27 | + <color name="default_header_layout_title_textColor">#fff</color> |
| 28 | + <dimen name="default_header_layout_title_textSize">20sp</dimen> |
| 29 | + <dimen name="default_header_layout_menu_textSize">15sp</dimen> |
| 30 | + |
| 31 | + <declare-styleable name="HeaderLayout"> |
| 32 | + <attr name="hlSupportTranslucentStatus" format="boolean"/> |
| 33 | + <attr name="hlTitleText" format="string"/> |
| 34 | + <attr name="hlTitleTextColor" format="color"/> |
| 35 | + <attr name="hlTitleTextSize" format="dimension"/> |
| 36 | + <attr name="hlItemTextColor" format="color"/> <!-- 所有按钮文字按钮颜色 --> |
| 37 | + <attr name="hlItemTextSize" format="dimension"/> <!-- 所有按钮文字按钮大小--> |
| 38 | + <attr name="hlItemTextPaddingLeftAndRight" format="dimension"/> <!-- 所有文字按钮左右间距 --> |
| 39 | + <attr name="hlNavigationIcon" format="reference"/> <!-- 返回按钮 or 左边按钮 图片 二选一 --> |
| 40 | + <attr name="hlNavigationText" format="reference"/> <!-- 返回按钮 or 左边按钮 文字 二选一 --> |
| 41 | + <attr name="hlNavigationWidth" format="dimension" /> |
| 42 | + <attr name="hlNavigationMinWidth" format="dimension" /> |
| 43 | + <attr name="hlNavigationMaxWidth" format="dimension" /> |
| 44 | + <attr name="hlNavigationHeight" format="dimension" /> |
| 45 | + <attr name="hlNavigationMinHeight" format="dimension" /> |
| 46 | + <attr name="hlNavigationMaxHeight" format="dimension" /> |
| 47 | + <attr name="hlNavigationScaleType" format="enum"> |
| 48 | + <enum name="matriX" value="0"/> |
| 49 | + <enum name="fitXY" value="1"/> |
| 50 | + <enum name="fitStart" value="2"/> |
| 51 | + <enum name="fitCenter" value="3"/> |
| 52 | + <enum name="fitEnd" value="4"/> |
| 53 | + <enum name="center" value="5"/> |
| 54 | + <enum name="centerCrop" value="6"/> |
| 55 | + <enum name="centerInside" value="7"/> |
| 56 | + </attr> |
| 57 | + <attr name="hlMenuIcon" format="reference"/> <!-- 右边按钮 --> |
| 58 | + <attr name="hlMenuIconId" format="reference"/> <!-- 右边按钮id --> |
| 59 | + <attr name="hlMenu2Icon" format="reference"/> <!-- 右边按钮 --> |
| 60 | + <attr name="hlMenu2IconId" format="reference"/> <!-- 右边按钮id --> |
| 61 | + <attr name="hlMenuText" format="string"/> <!-- 右边文字按钮 --> |
| 62 | + <attr name="hlMenuTextId" format="string"/> <!-- 右边文字按钮id --> |
| 63 | + <attr name="hlMenu2Text" format="string"/> <!-- 右边文字按钮 --> |
| 64 | + <attr name="hlMenu2TextId" format="string"/> <!-- 右边文字按钮id --> |
| 65 | + <attr name="hlMenuAlign" format="enum"> <!-- 右边按钮排序 --> |
| 66 | + <enum name="alignText" value="0"/> <!-- 文字在最右边 --> |
| 67 | + <enum name="alignIcon" value="1"/> <!-- 图标在最右边 --> |
| 68 | + <enum name="alternate" value="2"/> <!-- 图标 文字 图标 文字 --> |
| 69 | + <enum name="alternate2" value="3"/> <!-- 文字 图标 文字 图标 --> |
| 70 | + </attr> |
| 71 | + <attr name="hlSpitLineColor" format="reference"/> <!-- 底部分割线 --> |
| 72 | + <attr name="hlSpitLineHeight" format="dimension"/> <!-- 底部分割线 --> |
| 73 | + <attr name="hlTitleAlignLeft" format="boolean"/> <!-- 居左显示 --> |
| 74 | + </declare-styleable> |
| 75 | +</resources> |
| 76 | + |
| 77 | +**2、布局引用** |
| 78 | + |
| 79 | + <com.vendor.lib.widget.HeaderLayout |
| 80 | + android:layout_width="match_parent" |
| 81 | + android:layout_height="45dp" |
| 82 | + android:background="@drawable/title_bg" |
| 83 | + app:hlItemTextColor="@color/green" |
| 84 | + app:hlItemTextSize="13sp" |
| 85 | + app:hlNavigationMinWidth="45dp" |
| 86 | + app:hlTitleAlignLeft="true" |
| 87 | + app:hlNavigationScaleType="centerInside" |
| 88 | + app:hlNavigationIcon="@mipmap/back_btn" |
| 89 | + app:hlSupportTranslucentStatus="false" |
| 90 | + app:hlTitleText="@string/app_name" |
| 91 | + app:hlTitleTextColor="@color/black" |
| 92 | + app:hlTitleTextSize="18sp" |
| 93 | + app:hlMenuIcon="@mipmap/edit_ic" |
| 94 | + app:hlMenuIconId="@+id/edit_btn" |
| 95 | + app:hlMenuText="@string/edit" |
| 96 | + app:hlMenuTextId="@+id/edit_btn" |
| 97 | + app:hlMenu2Icon="@mipmap/add_ic" |
| 98 | + app:hlMenu2IconId="@+id/add_btn" |
| 99 | + app:hlMenu2Text="@string/add" |
| 100 | + app:hlMenu2TextId="@+id/add_btn" > |
| 101 | + |
| 102 | +有问题联系:QQ群 254202293 |
|
0 commit comments