在GitHub上的Android開原始碼SuperTextView的使用
每週一會分享一篇GitHub開源的專案
SuperTextView
一個功能強大的TextView,可以滿足日常大部分佈局方式,開發者可已自行組合屬性配置出屬於自己風格的樣式!
效果圖
基本使用
1.新增Gradle依賴
先在 build.gradle 的 repositories 新增:
allprojects {
repositories {
...
maven { url "https://jitpack.io" }
}
}
然後在dependencies新增:
dependencies {
...
compile 'com.allen.supertextview:supertextview:1.0.3'
}
2.佈局中如何使用
<com.allen.supertextviewlibrary.SuperTextView
android:id="@+id/super_tv"
android:layout_width="match_parent"
android:layout_height="80dp"
stv:sLeftBottomTextColor2="@color/colorAccent"
stv:sLeftBottomTextString="招商銀行(8888)"
stv:sLeftBottomTextString2="限額說明>>"
stv:sLeftIconRes="@drawable/bank_zhao_shang"
stv:sLeftTopTextString="銀行卡支付"
stv:sRightCheckBoxRes="@drawable/circular_check_bg"
stv:sRightCheckBoxShow="true"
stv:sLineShow="bottom"
/>
注意:
1、上下的線可以通過 sLineShow 設定 有四種顯示方式 none,top,bottom,both
2、通過設定 sUseRipple=true 開啟水波效果
3.程式碼中如何使用
/**
* 可以通過鏈式設定大部分常用的屬性值
*/
superTextView.setLeftIcon(drawable)
.setLeftString("")
.setLeftTVColor(0)
.setLeftTopString("")
.setLeftTopTVColor(0)
.setLeftBottomString("")
.setLeftBottomTVColor(0)
.setLeftBottomString2("")
.setLeftBottomTVColor2(0)
.setRightString("")
.setRightTVColor(0)
.setCbChecked(true)
.setCbBackground(drawable)
.setRightIcon(drawable)
.setRightString("")
.setRightTVColor(0)
.setLeftString("")
.setOnSuperTextViewClickListener(new SuperTextView.OnSuperTextViewClickListener() {
@Override
public void onSuperTextViewClick() {
super.onSuperTextViewClick();
//do something
}
@Override
public void onLeftTopClick() {
super.onLeftTopClick();
//do something
}
@Override
public void onLeftBottomClick() {
super.onLeftBottomClick();
//do something
}
@Override
public void onLeftBottomClick2() {
super.onLeftBottomClick2();
//do something
}
});
4.點選事件(可根據需求選擇實現某個點選事件)
superTextView.setOnSuperTextViewClickListener(new SuperTextView.OnSuperTextViewClickListener() {
@Override
public void onSuperTextViewClick() {
super.onSuperTextViewClick();
//do something
}
@Override
public void onLeftTopClick() {
super.onLeftTopClick();
//do something
}
@Override
public void onLeftBottomClick() {
super.onLeftBottomClick();
//do something
}
@Override
public void onLeftBottomClick2() {
super.onLeftBottomClick2();
//do something
}
});
5.屬性說明(以下屬性全部可以通過xml檔案配置和程式碼進行設定)
<declare-styleable name="SuperTextView">
<attr name="sLeftIconRes" format="reference"/>
<attr name="sRightIconRes" format="reference"/>
<attr name="sRightCheckBoxRes" format="reference"/>
<attr name="sLeftTextString" format="string"/>
<attr name="sCenterTextString" format="string"/>
<attr name="sRightTextString" format="string"/>
<attr name="sLeftTopTextString" format="string"/>
<attr name="sLeftBottomTextString" format="string"/>
<attr name="sLeftBottomTextString2" format="string"/>
<attr name="sTopLineMargin" format="dimension"/>
<attr name="sBottomLineMargin" format="dimension"/>
<attr name="sBothLineMargin" format="dimension"/>
<attr name="sLeftIconMarginLeft" format="dimension"/>
<attr name="sLeftTextMarginLeft" format="dimension"/>
<attr name="sLeftTopTextMarginLeft" format="dimension"/>
<attr name="sLeftBottomTextMarginLeft" format="dimension"/>
<attr name="sLeftBottomTextMarginLeft2" format="dimension"/>
<attr name="sRightIconMarginRight" format="dimension"/>
<attr name="sRightTextMarginRight" format="dimension"/>
<attr name="sRightCheckBoxMarginRight" format="dimension"/>
<attr name="sRightCheckBoxShow" format="boolean"/>
<attr name="sIsChecked" format="boolean"/>
<attr name="sUseRipple" format="boolean"/>
<attr name="sLeftTextSize" format="dimension"/>
<attr name="sLeftTopTextSize" format="dimension"/>
<attr name="sLeftBottomTextSize" format="dimension"/>
<attr name="sLeftBottomTextSize2" format="dimension"/>
<attr name="sRightTextSize" format="dimension"/>
<attr name="sCenterTextSize" format="dimension"/>
<attr name="sBackgroundColor" format="color"/>
<attr name="sLeftTextColor" format="color"/>
<attr name="sLeftTopTextColor" format="color"/>
<attr name="sLeftBottomTextColor" format="color"/>
<attr name="sLeftBottomTextColor2" format="color"/>
<attr name="sRightTextColor" format="color"/>
<attr name="sCenterTextColor" format="color"/>
<attr name="sLineShow" format="enum">
<enum name="none" value="0"/>
<enum name="top" value="1"/>
<enum name="bottom" value="2"/>
<enum name="both" value="3"/>
</attr>
</declare-styleable>
6.使用第三方庫(Picasso或者Glide)載入網路圖片
Picasso.with(this)
.load(url)
.placeholder(R.drawable.head_default)
.into((ImageView) superTextView.getView(SuperTextView.leftImageViewId));
獲取更多或者轉載請聯絡作者:QQ群322814924
關注下面訂閱號可獲取最新的全套Android學習視訊
http://mp.weixin.qq.com/s?__biz=MzI0NDYzMzg0OQ==&mid=2247483715&idx=1&sn=afd9b944088ab259e69063780e69b72e&chksm=e95b98d5de2c11c3552e6b7ae571a3a635737097abc550f2e3532b88b7e8552e417938e37ef1&mpshare=1&scene=23&srcid=1107PLUws0A48nWoyc3ip2Jh#rd
相關文章
- 怎樣在Github上託管開原始碼庫Github原始碼
- 大公司在github的開原始碼Github原始碼
- Github上如何找開原始碼Github原始碼
- Github上的iOS App原始碼 (中文)GithubiOSAPP原始碼
- swift在github上開源的地址SwiftGithub
- 使用Hexo在Github上搭建自己的部落格HexoGithub
- SuperTextView 最全開發指南TextView
- 在 Ubuntu 上使用原始碼安裝 OpenRestyUbuntu原始碼REST
- 要求GitHub提供洩露者資訊,Twitter證實其原始碼被公佈在GitHub上Github原始碼
- Android開源:SuperTextView-使用這個控制元件來提高你構建專案的效率AndroidTextView控制元件
- 網上的很多Android專案原始碼有用嗎?Android開發注意的地方。Android原始碼
- 使用TortoiseGit下載GitHub原始碼Github原始碼
- ProGuard 在 Android 上的使用姿勢Android
- 開原始碼庫Github使用者超140萬原始碼Github
- 在 Mac 上如何向 GitHub 提交程式碼?MacGithub
- Mac如何上傳專案原始碼至GitHubMac原始碼Github
- [譯] ProGuard 在 Android 上的使用姿勢Android
- android原始碼解析--ListView(上)Android原始碼View
- 使用eclipse來開發Android原始碼EclipseAndroid原始碼
- 對 github上的程式碼進行二開後,如何同步 github 上原作者的最新程式碼Github
- ffmpeg在iOS的使用-iFrameExtractor原始碼解析iOS原始碼
- 上傳你的程式碼到 -> GithubGithub
- 通過gitHub獲取vlc-Android原始碼GithubAndroid原始碼
- 使用 MediaCodec 在 Android 上進行硬解碼Android
- Android中IntentService的使用及其原始碼解析AndroidIntent原始碼
- GitHub + VSTS 開原始碼雙向同步Github原始碼
- android面試——開源框架的原始碼解析Android面試框架原始碼
- Github 上的 iOS 開源專案GithubiOS
- Github上關注量8000+的Android優秀開源元件GithubAndroid元件
- 上不了名校?可以在 GitHub 上讀他們的課程Github
- 使用 flex4 開發通用統計系統,釋出原始碼至githubFlex原始碼Github
- GitHub上受歡迎的Android UI LibraryGithubAndroidUI
- Android中HandlerThread的使用及原始碼解析Androidthread原始碼
- 在android上使用opencv的ocl模組遇到的問題(一)AndroidOpenCV
- 在github上寫部落格Github
- 下載Github上公開專案檔案方法#coding.net及git的使用方式#克隆 Github 上的專案Github
- 在Github上,如何成為一個為開源服務的園丁Github
- github上傳程式碼Github