YFAndroidLibs
關於(About)
這是抽取的工作日常工作代碼形成的一個庫,持續更新中。借鑑了一些網上現有的代碼,在後續的介紹中會逐一提及。本文是基於android的庫,後續會有iOS版本以及JS版本。
- 如何抽取
自定義view和佈局,然後加以封裝,形成aar包。
- 下載地址:github:https://github.com/commutescript以及maven倉庫。
功能(Features)
這個庫包含的主要內容有:
1. 起始頁splash
2. 第一次導航guidepage
3. 廣告banner
4. tab導航和分欄
5. 定位sqlite數據庫
6. 搜索框和界面
7. 自定義dialog和Toast
8. 一些常用的工具類,utils
9. 標籤佈局TagView
10.聯動佈局LInkageView
其中字體、顏色和背景的樣式均可自定義,一鍵設置。
導入(Usage)
1.導入aar包
在libs文件夾下,添加相應的aar包
在 repositories添加
android {
compileSdkVersion 24
buildToolsVersion "24.0.2"
....
repositories {
flatDir {
dirs 'libs'
}
}
}
在dependencies 中添加
dependencies {
compile(name:’yf_Library-release’, ext:’aar’)
}
2.maven導入
還在測試中,敬請期待!
代碼(Code)
以SplashVIew爲例:
在佈局中添加:
<com.github.yf_library.splash.SplashView
android:id="@+id/sp_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
在代碼中添加邏輯:
//設置閃屏圖片
` sp_view.setBg(getDrawable(R.drawable.guide1));
sp_view.setTime(t,new OnFinishListener() {
@Override
public void setFinish() {
// TODO Auto-generated method stub
Intent mIntent=new Intent(getApplicationContext(),CommonTestActivity.class);
startActivity(mIntent);
}
});
//設置點擊跳過
sp_view.setJumpClick(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Toast.makeText(TestActivity.this, "點擊跳過", 1).show();;
Intent mIntent=new Intent(getApplicationContext(),CommonTestActivity.class);
startActivity(mIntent);
}
});
`
部分效果圖(ScreenShot)
- SplashView截圖:
2.GuidePageView截圖
3.SerachView截圖
4.其他的還在測試中。敬請期待。