Coder Social home page Coder Social logo

lqroptionitemview's Introduction

LQROptionItemView

项目中常用选项条目布局控件

##一、简述: 在项目开发中经常遇到类似“设置”功能的需求,一般都要做一些简单的选项条目布局,一个条目可以会用到布局+多个控件(文本或图标),一个条目在xml中布局还算可以接受了,但如果一个设置界面的选项条目有10个,还是一样的布局,这样就显示特别臃肿了吧,而一般一个界面的选项条目有3个以上。为了解决上述问题,本项目诞生了,满足常规的选项条目布局需求,先看下效果。

image

##二、使用: ###1、在自己项目中添加本项目依赖:

compile 'com.lqr.optionitemview:library:1.0.7'

###2、在布局中使用(属性可选,不设置则不显示): 一般图标的高度是控件高度的一半,所以没有做该自定义属性,写死了。

<com.lqr.optionitemview.OptionItemView
    android:id="@+id/oiv"
    android:layout_width="match_parent"
    android:layout_height="60dp"
    android:background="#abcdef"
    app:left_image_margin_left="20dp"
    app:left_image_margin_right="20dp"
    app:left_src="@mipmap/ic_launcher"
    app:left_text="left"
    app:left_text_color="#f00"
    app:left_text_margin_left="20dp"
    app:left_text_size="15sp"
    app:right_image_margin_left="20dp"
    app:right_image_margin_right="20dp"
    app:right_src="@mipmap/ic_launcher"
    app:right_text="right"
    app:splite_mode="true"
    app:right_text_color="#f00"
    app:right_text_margin_right="20dp"
    app:right_text_size="16sp"
    app:title="title"
    app:title_color="#00f"/>

###3、点击事件

####1)拆分模式 需要设置split_mode=true,默认是false

oiv.setOnOptionItemClickListener(new OptionItemView.OnOptionItemClickListener() {
    @Override
    public void leftOnClick() {
        Toast.makeText(getApplicationContext(), "左边被点击", Toast.LENGTH_SHORT).show();
    }

    @Override
    public void centerOnClick() {
        Toast.makeText(getApplicationContext(), "中间被点击", Toast.LENGTH_SHORT).show();
    }

    @Override
    public void rightOnClick() {
        Toast.makeText(getApplicationContext(), "右边被点击", Toast.LENGTH_SHORT).show();
    }
});

####2)整体模式 需要设置split_mode=false,默认是false

oiv.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        Toast.makeText(getApplicationContext(), "整体被点击", Toast.LENGTH_SHORT).show();
    }
});

###4、代码动态修改属性

setTitleText(String text)
setTitleText(int stringId)
setTitleColor(int color)
setTitleSize(int sp)

setLeftText(String text)
setLeftText(int stringId)
setLeftTextSize(int sp)
setLeftTextColor(int color)
setLeftTextMarginLeft(int dp)
setLeftImageMarginLeft(int dp)
setLeftImageMarginRight(int dp)
setLeftImage(Bitmap bitmap)
showLeftImg(boolean flag)
showLeftText(boolean flag)

setRightImage(Bitmap bitmap)
setRightText(String text)
setRightText(int stringId)
setRightTextColor(int color)
setRightTextSize(int sp)
setRightTextMarginRight(int dp)
setRightImageMarginLeft(int dp)
setRightImageMarginRight(int dp)
showRightImg(boolean flag)
showRightText(boolean flag)

setSpliteMode(boolean spliteMode)
getSpliteMode()

###5、个别自定义属性解释 image

lqroptionitemview's People

Contributors

gitlqr avatar

Watchers

 avatar

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.