Coder Social home page Coder Social logo

ruffianzhong / rtextview Goto Github PK

View Code? Open in Web Editor NEW
378.0 10.0 67.0 6.87 MB

基于TextView 1.直接设置selector背景2.直接设置drawableLeft大小 3.圆角,圆形,背景/边框/文字根据状态变色

Java 100.00%
textview state selector drawableleft

rtextview's Issues

icon_src_unable

icon_src_unable这些设置icon的 是不是不能根据icon图片的大小自动展示对应的?必须设置icon_width和height?

代码设置RTextView出错

使用代码设置RTextView 圆形,运行报错,属性是仿照例子中的xml文件设置的属性。
RTextView rTextView = new RTextView(context);
ViewGroup.LayoutParams layoutParams = rTextView.getLayoutParams();
layoutParams.width = DensityUtils.dp2px(context,100);
layoutParams.height = DensityUtils.dp2px(context,100);
rTextView.setLayoutParams(layoutParams);
rTextView.setGravity(Gravity.CENTER);
rTextView.setTextColor(textColor);
rTextView.setBackgroundColorNormal(Color.GRAY);
rTextView.setCornerRadius(DensityUtils.dp2px(context,50));
rTextView.setText(“圆形”);
这是什么原因造成的啊?麻烦帮忙看看

加个slected状态

刚开始我挺困惑作者为什么加unable状态,后来想想登陆注册界面,图片选择的确定键等确实可以用。
不过我更希望的是selected,用的比较多,距几个例子

1、列表经常有一些状态性控件,通常拿到json字段之后判断用什么背景和字体色(当然,详情页也有)
2、常用的两张状态控件,收藏、点赞、tab等
3、选择器,底部弹出的少选项选择器,侧边栏搜索条件筛选、图片选择器等
4、列表多选和单选

need to updated: extends TextView Should change to AppCompatAutoCompleteTextView

感谢楼主分享,完美解决了我的问题。
不过有一点还是需要说明下
public class RTextView extends AppCompatAutoCompleteTextView{}
现在想自定义视图必须继承自这个类而不是TextView了。
这个类位于这个包下
import android.support.v7.widget.AppCompatAutoCompleteTextView;
希望楼主能进行下更新
其次特别提醒下其他朋友,使用的时候特别当心,这个不可省略,否则会报错。
[code=html]
xmlns:view="http://schemas.android.com/apk/res-auto"
[/code]

谢谢你的工作,但是有两个属性

谢谢你的工作,但是有两个常用的属性请增加一下,一个是 drawableTint,一个 drawable与text的距离,这两个一般比较常用。加上就更节省时间了。

修改建议

其实你能把点击效果换成水纹(ripple)的就更符合现在的material design,谢谢

控件足够小的时候,文字不能居中

    <com.ruffian.library.RTextView
        android:id="@+id/relation"
        android:layout_width="45dp"
        android:layout_height="15dp"
        android:gravity="center"
        android:singleLine="true"
        android:textColor="@color/orange_ff9d01"
        android:textSize="@dimen/font_22"
        app:background_normal="@color/yellow_fff6e8"
        app:border_color_normal="@color/orange_ffa71c"
        app:corner_radius="@dimen/dp_10"
        tools:text="asd" />

按照上面这种写法,asd没有居中显示。只有调大height,asd才会慢慢的居中

圆形时能否自适应圆角大小呢

针对完全圆形的场景还需要在xml里面写圆角半径,如果用这个控件时是自适应高宽,就无法显示指定圆角大小,需要用java代码显示设置,用起来不够优雅

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.