ExpandTextView

by hymanme

一个可折叠和展开的TextView控件,很实用。

208 Stars 35 Forks Last release: Not found Apache License 2.0 11 Commits 0 Releases

Available items

No Items, yet!

The developer of this repository has not created any items for sale yet. Need a bug fixed? Help with integration? A different license? Create a request here:

ExpandTextView

一个可折叠和展开的TextView控件

image

night

How to use

Add this to your build.gradle:

    dependencies {
      compile 'com.hymane.expandtextview:library:1.0.2'
    }

更新日志

3. 修复新版gradle编译之后点击展开崩溃
2. 兼容夜间模式,字体颜色请使用主题对应的颜色
1. 初版  

定义xml布局

    

自定义设置

    etv.setIndicateImage(R.drawable.ic_arrow_down_light_round);
        etv.setMinVisibleLines(5);
        etv.setContentTextSize(15);
        etv.setTitleTextSize(16);
        etv.setHintTextSize(12);
        etv.setContent("text");
        etv.setHintTextColor(Color.parseColor("#913242"));
        etv.setOnReadMoreListener(new OnReadMoreClickListener() {
            @Override
            public void onExpand() {
                Toast.makeText(MainActivity.this, "expand", Toast.LENGTH_SHORT).show();
            }

        @Override
        public void onFold() {
            Toast.makeText(MainActivity.this, "fold", Toast.LENGTH_SHORT).show();
        }
    });

可选项

//设置标题
public void setTitle(String title);
//设置内容文本
public void setContent(String content);
//展开后显示的文字
public void setFoldHint(String foldHint); 
//折叠起来后显示的文字
public void setExpandHint(String expandHint) ;
//标题颜色
public void setTitleTextColor(@ColorInt int titleTextColor);
//内容字体颜色
public void setContentTextColor(@ColorInt int contentTextColor);
//查看更多字体颜色
public void setHintTextColor(@ColorInt int hintTextColor);
//查看更多前面小图标(夜间模式请更换对应图标,或者使用兼容主题的图标)
public void setIndicateImage(@DrawableRes Drawable indicateImage);
public void setIndicateImage(@DrawableRes int indicateImageRes);

//最小显示行数 public void setMinVisibleLines(int minVisibleLines);

/**

  • 设置字体大小
  • @param titleTextSize 单位为sp
  • / public void setTitleTextSize(float titleTextSize);

/**

  • 设置字体大小
  • @param contentTextSize 单位为sp
  • / public void setContentTextSize(float contentTextSize); }

/**

  • 设置字体大小
  • @param hintTextSize 单位为sp
  • / public void setHintTextSize(float hintTextSize);

/**

  • 动画执行时间
  • @param animationDuration 单位毫秒
  • / public void setAnimationDuration(int animationDuration);

/**

  • 设置监听
  • @param mListener 展开和收缩按钮点击时回调
  • / public void setOnReadMoreListener(OnReadMoreClickListener mListener);

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.