介绍:
android加载框效果,本例子有几种效果弹出dialog,本例子主要自定义SVProgressHUD 类,
本例子来源:https://github.com/saiwu-bigkoo/Android-SVProgressHUD
主要代码如下:
public enum SVProgressHUDMaskType {
None, // 允许遮罩下面控件点击
Clear, // 不允许遮罩下面控件点击
Black, // 不允许遮罩下面控件点击,背景黑色半透明
Gradient, // 不允许遮罩下面控件点击,背景渐变半透明
ClearCancel, // 不允许遮罩下面控件点击,点击遮罩消失
BlackCancel, // 不允许遮罩下面控件点击,背景黑色半透明,点击遮罩消失
GradientCancel // 不允许遮罩下面控件点击,背景渐变半透明,点击遮罩消失
;
}
//创建实例并初始化
private static final SVProgressHUD getInstance(Context context) {
if (mSVProgressHUD == null) {
mSVProgressHUD = new SVProgressHUD();
mSVProgressHUD.context = context;
mSVProgressHUD.gravity = Gravity.CENTER;
mSVProgressHUD.initViews();
mSVProgressHUD.initDefaultView();
mSVProgressHUD.initAnimation();
}
if (context != null && context != mSVProgressHUD.context ){
mSVProgressHUD.context = context;
mSVProgressHUD.initViews();
}
return mSVProgressHUD;
}
通过加装dialog动画
Animation.AnimationListener outAnimListener = new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) { }
@Override
public void onAnimationEnd(Animation animation) {
dismissImmediately();
}
@Override
public void onAnimationRepeat(Animation animation) {
}
};
运行效果:
介绍:
H5做的商城客户端,效果和android原生客户端没多大区别,现在h5是越来越火了,
android的小伙伴们又遇到一个新的挑战了。本项目只能学习一下WebViewActivity使用,
但是由于js看不到,所以补发看到里面的方法,
主要代码:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_webview);
ButterKnife.bind(this);
String url = getIntent().getStringExtra(EXTRA_URL);
mWebView.setWebViewClient(new WebViewClient());
WebSettings webSettings = mWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
mWebView.loadUrl(url);
setupActionBar(url);
}
还有就是CustomTabActivityHelper类封装了
/**
* Opens the URL on a Custom Tab if possible. Otherwise fallsback to opening it on a WebView
*
* @param activity The host activity
* @param customTabsIntent a CustomTabsIntent to be used if Custom Tabs is available
* @param uri the Uri to be opened
* @param fallback a CustomTabFallback to be used if Custom Tabs is not available
*/
public static void openCustomTab(Activity activity,
CustomTabsIntent customTabsIntent,
Uri uri,
CustomTabFallback fallback) {
String packageName = CustomTabsHelper.getPackageNameToUse(activity);
//If we cant find a package name, it means there's no browser that supports
//Chrome Custom Tabs installed. So, we fallback to the webview
if (packageName == null) {
if (fallback != null) {
fallback.openUri(activity, uri);
}
} else {
customTabsIntent.intent.setPackage(packageName);
customTabsIntent.launchUrl(activity, uri);
}
}
/**
* Unbinds the Activity from the Custom Tabs Service
* @param activity the activity that is connected to the service
*/
public void unbindCustomTabsService(Activity activity) {
if (mConnection == null) return;
activity.unbindService(mConnection);
mClient = null;
mCustomTabsSession = null;
}