Hyena-菜单项View

作者: KnifeStone | 来源:发表于2017-05-19 19:06 被阅读0次
  • 先看下需求,下图是设置-开发者选项 里面的截图,里面有四种布局,不难看出他们有共同点,比如Title的样式是一样的,都有分割线等等。
设置-开发者选项.png
  • 鬣狗快速开发库中有一个自定义控件-MenuItemView。可以很好的实现上面的需求。
MenuItemView效果图
  • 举个粒子
xmlns:item="http://schemas.android.com/apk/res-auto"

<com.knifestone.hyena.view.viewgroup.MenuItemView
    android:layout_width="match_parent"
    android:layout_height="50dp"
    android:paddingLeft="10dp"
    android:paddingRight="10dp"
    item:iv_left_size="35dp"
    item:iv_left_src="@mipmap/ic_launcher"
    item:iv_right_src="@drawable/ic_chevron_right_black_24dp"
    item:tv_title_color="#000"
    item:tv_title_margin_left="10dp"
    item:tv_title_text="鬣狗"
    item:v_line_bottom_visibility="true" />
  • 属性介绍

  • 标题有5个属性
<attr name="tv_title_text" format="string" />
<attr name="tv_title_color" format="color" />
<attr name="tv_title_size" format="dimension" />
<attr name="tv_title_margin_left" format="dimension" />
<attr name="tv_title_margin_right" format="dimension" />
  • 副标题有6个属性
<attr name="tv_subtitle_text" format="string" />
<attr name="tv_subtitle_color" format="color" />
<attr name="tv_subtitle_size" format="dimension" />
<attr name="tv_subtitle_margin_left" format="dimension" />
<attr name="tv_subtitle_margin_right" format="dimension" />
<attr name="tv_subtitle_gravity" format="integer">
    <enum name="left" value="0" />
    <enum name="right" value="1" />
    <enum name="bottom" value="2" />
</attr>
  • 左边icon有3个属性
<attr name="iv_left_src" format="reference" />
<attr name="iv_left_size" format="dimension" />
<attr name="iv_left_margin_left" format="dimension" />
  • 右边icon有3个属性
<attr name="iv_right_src" format="reference" />
<attr name="iv_right_size" format="dimension" />
<attr name="iv_right_margin_right" format="dimension" />
  • Switch 2个属性
<attr name="switch_visibility" format="boolean" />
<attr name="switch_checked" format="boolean" />
  • 上、下两条分割线的相关属性
<attr name="v_line_color" format="color" />

<attr name="v_line_top_visibility" format="boolean" />
<attr name="v_line_top_margin_left" format="dimension" />
<attr name="v_line_top_margin_right" format="dimension" />
<attr name="v_line_top_margin_height" format="dimension" />

<attr name="v_line_bottom_visibility" format="boolean" />
<attr name="v_line_bottom_margin_left" format="dimension" />
<attr name="v_line_bottom_margin_right" format="dimension" />
<attr name="v_line_bottom_margin_height" format="dimension" />
  • java中公开的方法
setTitle                    | 设置标题
setSubTitle                 | 设置副标题
setOnCheckedChangeListener  | 设置Switch监听
setChecked                  | 设置Switch
getChecked                  | 获得Switch
高效、精准鬣狗开发而生。更多功能关注Github

相关文章

网友评论

    本文标题:Hyena-菜单项View

    本文链接:https://www.haomeiwen.com/subject/husrtxtx.html