幸福别等,世事别怕!
ruffianzhong / rtextview Goto Github PK
View Code? Open in Web Editor NEW基于TextView 1.直接设置selector背景2.直接设置drawableLeft大小 3.圆角,圆形,背景/边框/文字根据状态变色
基于TextView 1.直接设置selector背景2.直接设置drawableLeft大小 3.圆角,圆形,背景/边框/文字根据状态变色
感谢楼主分享,完美解决了我的问题。
不过有一点还是需要说明下
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的距离,这两个一般比较常用。加上就更节省时间了。
针对完全圆形的场景还需要在xml里面写圆角半径,如果用这个控件时是自适应高宽,就无法显示指定圆角大小,需要用java代码显示设置,用起来不够优雅
demo里面,可否来一个普通控件设置shape和你的控件设置shape在RecycleView渲染时间对比
刚开始我挺困惑作者为什么加unable状态,后来想想登陆注册界面,图片选择的确定键等确实可以用。
不过我更希望的是selected,用的比较多,距几个例子
1、列表经常有一些状态性控件,通常拿到json字段之后判断用什么背景和字体色(当然,详情页也有)
2、常用的两张状态控件,收藏、点赞、tab等
3、选择器,底部弹出的少选项选择器,侧边栏搜索条件筛选、图片选择器等
4、列表多选和单选
<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才会慢慢的居中
icon_src_unable这些设置icon的 是不是不能根据icon图片的大小自动展示对应的?必须设置icon_width和height?
能设置边框阴影吗?
如题
其实你能把点击效果换成水纹(ripple)的就更符合现在的material design,谢谢
我项目里面用的图标很多都是VectorDrawable(矢量图) 在5.0以上可以正常 以下会奔溃,我查资料 发现需要一些适配https://github.com/woxingxiao/VectorCompatTextView
使用代码设置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(“圆形”);
这是什么原因造成的啊?麻烦帮忙看看
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.