Giter Club home page Giter Club logo

settingview's Introduction

SettingView

现在市面上许多应用在个人中心或者设置中心都有条目,每次都会写这些无用的代码,所以做了一个简单的组合控件,简单省时,方便开发.

先上图

快速使用

1.添加依赖
compile 'com.jeff:settingitem:1.0'
2.在布局文件中引用
<com.jeff.settingitem.SettingView
        android:layout_width="match_parent"
        android:layout_height="44dp"
        app:item_background="@drawable/selector_item"
        app:item_text="消息"
        app:left_icon="@mipmap/icon_per_infor"
        app:show_dot="true"
        app:text_size="16sp" />
3.添加点击事件
SettingView mItem = (SettingView) findViewById(R.id.setting);
        mItem.setOnItemViewClick(new SettingView.OnItemViewClick() {
            @Override
            public void itemClick() {
                //do something
            }
        });
4.对外提供设置方法
mItem.setItemText("消息");    //设置条目文字
mItem.showDot(false);       //是否显示红点
mItem.showRightIcon(true);      //是否显示右边icon
mItem.showLeftIcon(true);       //是否显示左边icon
5.xml中的自定义属性
属性 说明 类型
item_text 条目文字 string
item_background 条目背景 reference
left_icon 左侧图标 reference
right_icon 右侧图标 reference
text_size 文字大小 dimension
text_color 文字颜色 color
show_left_icon 是否显示左侧图标(默认显示) boolean
show_right_icon 是否显示右侧图标(默认显示) boolean
show_dot 是否显示小红点(默认不显示) boolean
left_icon_margin_left 左侧图标距离左边margin dimension
text_margin_left 文字距离左边图标margin dimension
right_icon_margin_right 右侧图标距离右边margin dimension

欢迎大家star,有什么问题可以issue.欢迎访问我的博客 查看更多文章。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.