All Projects → goweii → RevealLayout

goweii / RevealLayout

Licence: LGPL-3.0 license
揭示效果布局,可以指定2个子布局,以圆形揭示效果切换选中状态

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to RevealLayout

Jc button
Arduino library to debounce button switches, detect presses, releases, and long presses
Stars: ✭ 289 (+144.92%)
Mutual labels:  button, switch
MGS.Electronics
Unity plugin for make button switch, knob switch and rocker element in scene.
Stars: ✭ 12 (-89.83%)
Mutual labels:  button, switch
CompositeToggle
Composite toggle system for unity
Stars: ✭ 38 (-67.8%)
Mutual labels:  toggle, switch
SweetLike
A beautiful like button written in Swift.
Stars: ✭ 13 (-88.98%)
Mutual labels:  like, button
Easybutton
Arduino library for debouncing momentary contact switches, detect press, release, long press and sequences with event definitions and callbacks.
Stars: ✭ 187 (+58.47%)
Mutual labels:  button, switch
Vue Js Toggle Button
🍥 Vue.js 2 toggle / switch button - simple, pretty, customizable
Stars: ✭ 836 (+608.47%)
Mutual labels:  button, switch
PygameWidgets
A module for use with Pygame. Includes fully customisable buttons, textboxes, sliders and many more, as well as the ability to create and run animations on these widgets.
Stars: ✭ 34 (-71.19%)
Mutual labels:  toggle, switch
Aiflatswitch
Nicely animated flat design switch alternative to UISwitch
Stars: ✭ 904 (+666.1%)
Mutual labels:  button, switch
Tristatetogglebutton
Customizable tri-state toggle button (with three states, three state toggle) for Android
Stars: ✭ 198 (+67.8%)
Mutual labels:  button, switch
ng-toggle
Bootstrap-styled Angular Toggle Component
Stars: ✭ 14 (-88.14%)
Mutual labels:  toggle, switch
lily
Hosts管理工具,双击切换立即生效,告别重启浏览器! Hosts manager takes effect immediately on switch
Stars: ✭ 69 (-41.53%)
Mutual labels:  switch
GlowButton
Beautify your layouts with glowing buttons. Support with a ⭐️ Contributions are welcome! 🙌
Stars: ✭ 54 (-54.24%)
Mutual labels:  button
like-mysql
Simple and intuitive ORM for MySQL
Stars: ✭ 24 (-79.66%)
Mutual labels:  like
emusak-ui
This is a tool which allows you to download saves or mods for Nintendo Switch emulators using a compatible Emusak backend
Stars: ✭ 877 (+643.22%)
Mutual labels:  switch
react-native-radio-buttons-group
Simple, best and easy to use radio buttons for react native apps.
Stars: ✭ 145 (+22.88%)
Mutual labels:  button
rcli
Simplified R version handling
Stars: ✭ 33 (-72.03%)
Mutual labels:  switch
jw-bootstrap-switch-ng2
Bootstrap Switch for Angular 2+
Stars: ✭ 45 (-61.86%)
Mutual labels:  switch
buttons tabbar
A Flutter package that implements a TabBar where each label is a toggle button.
Stars: ✭ 49 (-58.47%)
Mutual labels:  button
MultiToggleButton
Multiple state tap-to-toggle UIButton (like old camera flash button)
Stars: ✭ 81 (-31.36%)
Mutual labels:  toggle
wp-showhide
Allows you to embed content within your blog post via WordPress ShortCode API and toggling the visibility of the cotent via a link.
Stars: ✭ 21 (-82.2%)
Mutual labels:  toggle

求职

RevealLayout

揭示效果布局,可以指定2个子布局,以圆形揭示效果切换选中状态

GitHub主页

Demo下载

截图

集成方式

添加依赖

  1. 在项目根目录的build.gradle添加仓库地址
allprojects {
	repositories {
		...
		maven { url 'https://www.jitpack.io' }
	}
}
  1. 在项目app目录的build.gradle添加依赖

从1.1.1版本开始,版本号前不加v,引用时需要注意。

dependencies {
	implementation 'com.github.goweii:RevealLayout:1.1.1'
}

布局文件引用

<per.goweii.reveallayout.RevealLayout
	android:layout_width="wrap_content"
	android:layout_height="wrap_content"
	android:layout_margin="5dp"
	app:rl_allow_revert="true"
	app:rl_anim_duration="1000"
	app:rl_check_with_expand="true"
	app:rl_checked="false"
	app:rl_checked_layout="@layout/reveal_layout_follow_checked"
	app:rl_uncheck_with_expand="true"
	app:rl_unchecked_layout="@layout/reveal_layout_follow_unchecked" />

代码中设置监听

revealLayout.setOnCheckedChangeListener(new RevealLayout.OnCheckedChangeListener() {
    @Override
    public void onCheckedChanged(RevealLayout revealLayout, boolean isChecked) {
        // TODO 
    }
});

自定义子类

如一个关注取消关注控件FollowView,只需要继承RevealLayout,然后复写以下3个方法:

  1. initAttr(AttributeSet attrs):获取子类的自定义属性
  2. createCheckedView():创建选中状态视图,并初始化自定义属性
  3. createUncheckedView():创建非选中状态视图,并初始化自定义属性
public class FollowView extends RevealLayout{
    private float mTvTextSize;
    private int mTvPaddingVertical = 0;
    private int mTvPaddingHorizontal = 0;
    private String mTvUnFollowText = "";
    private int mTvUnFollowBgColor;
    private int mTvUnFollowBgRes;
    private int mTvUnFollowTextColor;
    private String mTvFollowText = "";
    private int mTvFollowBgColor;
    private int mTvFollowBgRes;
    private int mTvFollowTextColor;

    public FollowView(Context context) {
        this(context, null);
    }

    public FollowView(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public FollowView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    protected void initAttr(AttributeSet attrs) {
        super.initAttr(attrs);
        DisplayMetrics metrics = getContext().getResources().getDisplayMetrics();
        TypedArray array = getContext().obtainStyledAttributes(attrs, R.styleable.FollowView);
        mTvPaddingVertical = (int) array.getDimension(R.styleable.FollowView_fv_tv_padding_vertical, 0F);
        mTvPaddingHorizontal = (int) array.getDimension(R.styleable.FollowView_fv_tv_padding_horizontal, 0F);
        mTvTextSize = array.getDimension(R.styleable.FollowView_fv_text_size, metrics.scaledDensity * 14) / metrics.scaledDensity;
        mTvUnFollowText = array.getString(R.styleable.FollowView_fv_unfollowed_text);
        mTvUnFollowBgRes = array.getResourceId(R.styleable.FollowView_fv_unfollowed_bg_res, 0);
        mTvUnFollowBgColor = array.getColor(R.styleable.FollowView_fv_unfollowed_bg_color, 0);
        mTvUnFollowTextColor = array.getColor(R.styleable.FollowView_fv_unfollowed_text_color, 0);
        mTvFollowText = array.getString(R.styleable.FollowView_fv_followed_text);
        mTvFollowBgRes = array.getResourceId(R.styleable.FollowView_fv_followed_bg_res, 0);
        mTvFollowBgColor = array.getColor(R.styleable.FollowView_fv_followed_bg_color, 0);
        mTvFollowTextColor = array.getColor(R.styleable.FollowView_fv_followed_text_color, 0);
        array.recycle();
    }

    @Override
    protected View createCheckedView() {
        TextView tvFollow = new TextView(getContext());
        tvFollow.setTextSize(mTvTextSize);
        tvFollow.setText(mTvFollowText);
        tvFollow.setGravity(Gravity.CENTER);
        tvFollow.setSingleLine();
        if (mTvFollowBgRes > 0) {
            tvFollow.setBackgroundResource(mTvFollowBgRes);
        } else {
            tvFollow.setBackgroundColor(mTvFollowBgColor);
        }
        tvFollow.setTextColor(mTvFollowTextColor);
        tvFollow.setPadding(mTvPaddingHorizontal, mTvPaddingVertical, mTvPaddingHorizontal, mTvPaddingVertical);
        return tvFollow;
    }

    @Override
    protected View createUncheckedView() {
        TextView tvUnFollow = new TextView(getContext());
        tvUnFollow.setTextSize(mTvTextSize);
        tvUnFollow.setText(mTvUnFollowText);
        tvUnFollow.setGravity(Gravity.CENTER);
        tvUnFollow.setSingleLine();
        if (mTvUnFollowBgRes > 0) {
            tvUnFollow.setBackgroundResource(mTvUnFollowBgRes);
        } else {
            tvUnFollow.setBackgroundColor(mTvUnFollowBgColor);
        }
        tvUnFollow.setTextColor(mTvUnFollowTextColor);
        tvUnFollow.setPadding(mTvPaddingHorizontal, mTvPaddingVertical, mTvPaddingHorizontal, mTvPaddingVertical);
        return tvUnFollow;
    }
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].