SuperTextView是一个功能强大的浏览,可以满足日常大部分布局样式,开发者可已自行组合属性配置!可能描述起来没有概念,还是直接看效果图吧!
SuperButton拥有形状文件的大部分属性,从此写形状属性变得非常简单
CommonTextView只是SuperTextView的逻辑简化,其实功能并不差少哦,有兴趣的可以看看
如果觉得对你有用的话,点一下右上的星星赞一下吧!
先在项目根目录的build.gradle的存储库添加:
allprojects {
repositories {
...
maven { url "https://jitpack.io" }
}
}
然后在依赖添加:
dependencies {
...
compile 'com.github.lygttpod:SuperTextView:2.1.6'
}
重写SuperTextView,功能更加全面,部分方法及属性有变更,1.x的版本的老用户请注意
<com.allen.library.SuperTextView
android:layout_width="match_parent"
android:layout_height="80dp"
stv:sCenterBottomTextColor="@color/colorAccent"
stv:sCenterBottomTextString="限额说明>>"
stv:sCenterTopTextString=" "
stv:sCenterViewGravity="left_center"
stv:sLeftBottomTextString="招商银行(8888)"
stv:sLeftIconRes="@drawable/bank_zhao_shang"
stv:sLeftTopTextString="银行卡支付"
stv:sLeftViewGravity="left_center"
stv:sRightCheckBoxRes="@drawable/circular_check_bg"
stv:sRightViewType="checkbox" />
注意:
1、上下的线可以通过 sDividerLineType 设置 有四种显示方式 none,top,bottom,both
2、通过设置 sUseRipple=true 开启水波效果
/**
* 可以通过链式设置大部分常用的属性值
*/
superTextView.setLeftTopString("")
.setLeftString("")
.setLeftBottomString("")
.setCenterTopString("")
.setCenterString("")
.setCenterBottomString("")
.setRightTopString("")
.setRightString("")
.setRightBottomString("")
.setLeftIcon(0)
.setRightIcon(0)
.setCbChecked(true)
.setCbBackground(null)
.setLeftTvDrawableLeft(null)
.setLeftTvDrawableRight(null)
.setCenterTvDrawableLeft(null)
.setCenterTvDrawableRight(null)
.setRightTvDrawableLeft(null)
.setRightTvDrawableRight(null);
superTextView.setShapeCornersRadius(20)
.setShapeCornersTopLeftRadius(20)
.setShapeCornersBottomLeftRadius(20)
.setShapeCornersTopRightRadius(20)
.setShapeCornersBottomRightRadius(20)
.setShapeStrokeColor(getResources().getColor(R.color.colorPrimary))
.setShapeStrokeWidth(1)
.setShapeSrokeDashWidth(1)
.setShapeStrokeDashGap(5)
.setShapeSolidColor(getResources().getColor(R.color.white))
.setShapeSelectorNormalColor(getResources().getColor(R.color.red_btn))
.setShapeSelectorPressedColor(getResources().getColor(R.color.gray))
.useShape();//设置完各个参数之后这句调用才生效
/**
* 根据实际需求对需要的View设置点击事件
*/
/**
* 根据实际需求对需要的View设置点击事件
*/
superTextView.setOnSuperTextViewClickListener(new SuperTextView.OnSuperTextViewClickListener() {
@Override
public void onClickListener(SuperTextView superTextView) {
string = "整个item的点击事件";
Toast.makeText(ClickActivity.this, string, Toast.LENGTH_SHORT).show();
}
}).setLeftTopTvClickListener(new SuperTextView.OnLeftTopTvClickListener() {
@Override
public void onClickListener() {
string = superTextView.getLeftTopString();
Toast.makeText(ClickActivity.this, string, Toast.LENGTH_SHORT).show();
}
}).setLeftTvClickListener(new SuperTextView.OnLeftTvClickListener() {
@Override
public void onClickListener() {
string = superTextView.getLeftString();
Toast.makeText(ClickActivity.this, string, Toast.LENGTH_SHORT).show();
}
}).setLeftBottomTvClickListener(new SuperTextView.OnLeftBottomTvClickListener() {
@Override
public void onClickListener() {
string = superTextView.getLeftBottomString();
Toast.makeText(ClickActivity.this, string, Toast.LENGTH_SHORT).show();
}
}).setCenterTopTvClickListener(new SuperTextView.OnCenterTopTvClickListener() {
@Override
public void onClickListener() {
string = superTextView.getCenterTopString();
Toast.makeText(ClickActivity.this, string, Toast.LENGTH_SHORT).show();
}
}).setCenterTvClickListener(new SuperTextView.OnCenterTvClickListener() {
@Override
public void onClickListener() {
string = superTextView.getCenterString();
Toast.makeText(ClickActivity.this, string, Toast.LENGTH_SHORT).show();
}
}).setCenterBottomTvClickListener(new SuperTextView.OnCenterBottomTvClickListener() {
@Override
public void onClickListener() {
string = superTextView.getCenterBottomString();
Toast.makeText(ClickActivity.this, string, Toast.LENGTH_SHORT).show();
}
}).setRightTopTvClickListener(new SuperTextView.OnRightTopTvClickListener() {
@Override
public void onClickListener() {
string = superTextView.getRightTopString();
Toast.makeText(ClickActivity.this, string, Toast.LENGTH_SHORT).show();
}
}).setRightTvClickListener(new SuperTextView.OnRightTvClickListener() {
@Override
public void onClickListener() {
string = superTextView.getRightString();
Toast.makeText(ClickActivity.this, string, Toast.LENGTH_SHORT).show();
}
}).setRightBottomTvClickListener(new SuperTextView.OnRightBottomTvClickListener() {
@Override
public void onClickListener() {
string = superTextView.getRightBottomString();
Toast.makeText(ClickActivity.this, string, Toast.LENGTH_SHORT).show();
}
}).setLeftImageViewClickListener(new SuperTextView.OnLeftImageViewClickListener() {
@Override
public void onClickListener(ImageView imageView) {
Toast.makeText(ClickActivity.this, "左边图片", Toast.LENGTH_SHORT).show();
}
}).setRightImageViewClickListener(new SuperTextView.OnRightImageViewClickListener() {
@Override
public void onClickListener(ImageView imageView) {
Toast.makeText(ClickActivity.this, "右边图片", Toast.LENGTH_SHORT).show();
}
});
superTextView_cb.setOnSuperTextViewClickListener(new SuperTextView.OnSuperTextViewClickListener() {
@Override
public void onClickListener(SuperTextView superTextView) {
superTextView.setCbChecked(!superTextView.getCbisChecked());
}
}).setCheckBoxCheckedChangeListener(new SuperTextView.OnCheckBoxCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
Toast.makeText(ClickActivity.this, "" + isChecked, Toast.LENGTH_SHORT).show();
}
});
superTextView_switch.setOnSuperTextViewClickListener(new SuperTextView.OnSuperTextViewClickListener() {
@Override
public void onClickListener(SuperTextView superTextView) {
superTextView.setSwitchIsChecked(!superTextView.getSwitchIsChecked());
}
}).setSwitchCheckedChangeListener(new SuperTextView.OnSwitchCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
Toast.makeText(ClickActivity.this, "" + isChecked, Toast.LENGTH_SHORT).show();
}
});
String url1 = "https://ss1.baidu.com/6ONXsjip0QIZ8tyhnq/it/u=3860616424,1789830124&fm=80&w=179&h=119&img.PNG";
String url2 = "https://ss0.baidu.com/6ONWsjip0QIZ8tyhnq/it/u=219781665,3032880226&fm=80&w=179&h=119&img.JPEG";
String url3 = "https://ss1.baidu.com/6ONXsjip0QIZ8tyhnq/it/u=3860616424,1789830124&fm=80&w=179&h=119&img.PNG";
Picasso.with(this)
.load(url1)
.placeholder(R.drawable.head_default)
.into(superTextView.getLeftIconIV());
Glide.with(this)
.load(url2)
.placeholder(R.drawable.head_default)
.fitCenter()
.into(superTextView2.getRightIconIV());
Glide.with(this)
.load(url3)
.placeholder(R.drawable.head_default)
.into(new SimpleTarget<GlideDrawable>() {
@Override
public void onResourceReady(GlideDrawable resource, GlideAnimation<? super GlideDrawable> glideAnimation) {
superTextView3.setRightTvDrawableRight(resource);
}
});
热门源码