一:推荐Android15个常用的图表库,包含线性,条形柱状,饼状图,扇形,雷达,股票,折线,散点,仪表盘...
https://blog.csdn.net/u014133119/article/details/80923327
HelloCharts:
http://www.jcodecraeer.com/a/anzhuokaifa/androidkaifa/2014/1107/1930.html
二::Retrofit+RxJava的依赖:
// Okhttp库
implementation 'com.squareup.okhttp3:okhttp:3.11.0'
implementation 'com.squareup.okhttp3:logging-interceptor:3.8.1'
// Retrofit库
implementation 'com.squareup.retrofit2:retrofit:2.1.0'
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.2.0'
//RxJava
implementation 'io.reactivex.rxjava2:rxjava:2.0.1'
implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
三: TextView/string.xml冷门小技巧:占位转换符%1$s、%1$d等的用法:
https://www.jianshu.com/p/e9fd92fd0951
四: EditText有光标不弹出软键盘:
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
try {
Class<EditText> cls = EditText.class;
Method setSoftInputShownOnFocus;
setSoftInputShownOnFocus = cls.getMethod("setShowSoftInputOnFocus", boolean.class);
setSoftInputShownOnFocus.setAccessible(true);
setSoftInputShownOnFocus.invoke(mEditText, false);
} catch (Exception e) {
e.printStackTrace();
}
五:烟花试的下拉效果:
网址:https://github.com/Cleveroad/FireworkyPullToRefresh
六:【Android珍藏】推荐10个炫酷的开源库:
https://www.jianshu.com/p/d608f0228fd4
七: Android FlycoTabLayout:滑动标签
八:设置沉浸式:
StatusBarUtils:
package com.project.charttext;
import android.app.Activity;
import android.content.Context;
import android.graphics.Color;
import android.os.Build;
import android.support.annotation.ColorInt;
import android.support.v4.view.ViewCompat;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.LinearLayout;
/**
* @author
* @date 2019/5/15 13:44
*/
public class StatusBarUtils {
public static void setColor(Activity activity, @ColorInt int color, int statusBarAlpha){
//先设置的全屏模式
setFullScreen(activity);
//在透明状态栏的垂直下方放置一个和状态栏同样高宽的view
addStatusBarBehind(activity,color,statusBarAlpha);
}
/**
* 添加了一个状态栏(实际上是个view),放在了状态栏的垂直下方
*/
public static void addStatusBarBehind(Activity activity, @ColorInt int color, int statusBarAlpha) {
//获取windowphone下的decorView
ViewGroup decorView = (ViewGroup) activity.getWindow().getDecorView();
int count = decorView.getChildCount();
//判断是否已经添加了statusBarView
if (count > 0 && decorView.getChildAt(count - 1) instanceof StatusBarView) {
decorView.getChildAt(count - 1).setBackgroundColor(calculateStatusColor(color, statusBarAlpha));
} else {
//新建一个和状态栏高宽的view
StatusBarView statusView = createStatusBarView(activity, color, statusBarAlpha);
decorView.addView(statusView);
}
setRootView(activity);
}
public static void setTranslucentImageHeader(Activity activity, int alpha,View needOffsetView){
setFullScreen(activity);
//获取windowphone下的decorView
ViewGroup decorView = (ViewGroup) activity.getWindow().getDecorView();
int count = decorView.getChildCount();
//判断是否已经添加了statusBarView
if (count > 0 && decorView.getChildAt(count - 1) instanceof StatusBarView) {
decorView.getChildAt(count - 1).setBackgroundColor(Color.argb(alpha, 0, 0, 0));
} else {
//新建一个和状态栏高宽的view
StatusBarView statusView = createTranslucentStatusBarView(activity, alpha);
decorView.addView(statusView);
}
if (needOffsetView != null) {
ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams) needOffsetView.getLayoutParams();
layoutParams.setMargins(0, getStatusBarHeight(activity), 0, 0);
}
}
private static StatusBarView createTranslucentStatusBarView(Activity activity, int alpha) {
// 绘制一个和状态栏一样高的矩形
StatusBarView statusBarView = new StatusBarView(activity);
LinearLayout.LayoutParams params =
new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, getStatusBarHeight(activity));
statusBarView.setLayoutParams(params);
statusBarView.setBackgroundColor(Color.argb(alpha, 0, 0, 0));
return statusBarView;
}
/**
* 设置根布局参数
*/
private static void setRootView(Activity activity) {
ViewGroup rootView = (ViewGroup) ((ViewGroup) activity.findViewById(android.R.id.content)).getChildAt(0);
//rootview不会为状态栏流出状态栏空间
ViewCompat.setFitsSystemWindows(rootView,true);
rootView.setClipToPadding(true);
}
private static StatusBarView createStatusBarView(Activity activity, int color, int alpha) {
// 绘制一个和状态栏一样高的矩形
StatusBarView statusBarView = new StatusBarView(activity);
LinearLayout.LayoutParams params =
new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, getStatusBarHeight(activity));
statusBarView.setLayoutParams(params);
statusBarView.setBackgroundColor(calculateStatusColor(color, alpha));
return statusBarView;
}
/**
* 获取状态栏高度
*
* @param context context
* @return 状态栏高度
*/
private static int getStatusBarHeight(Context context) {
// 获得状态栏高度
int resourceId = context.getResources().getIdentifier("status_bar_height", "dimen", "android");
return context.getResources().getDimensionPixelSize(resourceId);
}
/**
* 计算状态栏颜色
*
* @param color color值
* @param alpha alpha值
* @return 最终的状态栏颜色
*/
private static int calculateStatusColor(int color, int alpha) {
float a = 1 - alpha / 255f;
int red = color >> 16 & 0xff;
int green = color >> 8 & 0xff;
int blue = color & 0xff;
red = (int) (red * a + 0.5);
green = (int) (green * a + 0.5);
blue = (int) (blue * a + 0.5);
return 0xff << 24 | red << 16 | green << 8 | blue;
}
public static void setFullScreen(Activity activity){
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
Window window = activity.getWindow();
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS
| WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN| View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.setStatusBarColor(Color.TRANSPARENT);
}else
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
// 设置透明状态栏,这样才能让 ContentView 向上
activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
}
}
public static class StatusBarView extends View {
public StatusBarView(Context context) {
super(context);
}
public StatusBarView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public StatusBarView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
}
}
使用方法:直接调用就可以
eg:(0—250)透明度,0的时候为透明,通过设置UItil中的argb,来调整状态栏的颜色
StatusBarUtils.setTranslucentImageHeader(this,250,view);
九:各种控件网址(很全)
https://hndeveloper.github.io/2017/github-android-ui.html#SwitchButton
十:Android 第三方开源库(持续更新,好多干货,包你喜欢)
https://www.jianshu.com/p/f64df400e16f
十一:CollapsingToolbarLayout+FloatingActionButton 打造精美详情界面(转发)
https://blog.csdn.net/smile_Running/article/details/97183522
十二:新的图片选择框架:YImagePicker
- 支持无缝切换小红书剪裁样式并自定义UI
- 支持微信、马蜂窝、知乎等多个不同风格样式定制
- 支持图片直接预览和编辑预览(排序、删除)
- 支持单图自定义比例剪裁
- 支持视频、图片、GIF图等不同类型混合加载
- 支持视频图片混合单选或多选
- 支持高清预览超长图、超大图,图片放大效果胜过微信
- 小红书剪裁样式支持视频预览
- 微信样式支持指定单一类型选择(图片、视频)
- 微信样式支持多次选择状态保存
- 微信样式支持指定某些媒体文件不可选择
- 选择结果直接回调,拒绝配置ActivityForResult+requestCode,即调用即处理
- 轻量级,aar大小不超过300K,无so库,无任何第三方依赖
- 支持androidx和support
- 永久维护
网址:https://www.wanandroid.com/blog/show/2686
项目地址:https://github.com/yangpeixing/YImagePicker
十三:自定义控件通用库 WidgetCase
这里边有很多自定义的统计图、环装图等等;内容很丰富;有效果图,可以看看
网址:https://www.wanandroid.com/blog/show/2683
项目地址:https://github.com/faith-hb/WidgetCase
十四:Android稳定高效的浮层创建管理框架
各种弹框;样式挺丰富;满足你的需求。
网址:https://www.wanandroid.com/blog/show/2671
项目地址:https://github.com/goweii/AnyLayer
十五:Android各种样式、时尚的弹框效果
Android功能强大,UI简洁,交互优雅的通用弹窗!可以替代Dialog,PopupWindow,PopupMenu,BottomSheet,DrawerLayout,Spinner等组件,自带十几种效果良好的动画,完全支持UI和动画自定义!(功能强大和漂亮的弹出窗口,可以绝对替换Dialog,PopupWindow,PopupMenu,BottomSheet,DrawerLayout,Spinner。带有内置动画制作器,非常易于自定义弹出窗口。)
网址:https://github.com/li-xiaojun/XPopup