Chrome Custom Tabs
来源:互联网 发布:thinking in java 5 编辑:程序博客网 时间:2024/05/21 11:19
Chrome Custom Tabs 标签优点
Chrome自定义标签页(Custom Tabs)将允许应用预加载,从而将网页的加载时间直接减半。
它的速度比WebView更快,预加载的效果甚至好于Chrome本身。
持良好的用户体验,并且让用户感觉这个自定义 Tab 就是您应用的一部分。
使用方法比WebView 简单,只需要一行代码,和直接调用系统浏览器显示网页没啥区别
有大量自定义属性,改善用户体验
使用方法
需要导入Custom Tabs 的支持包:
compile ‘com.android.support:customtabs:23.1.0’
最简单的使用方式是只需要使用 CustomTabsIntent.Builder 对象来设置一些常用自定义选项,然后调用 CustomTabsIntent.launchUrl(Activity context, Uri url) 函数即可。当然在具体使用过程中,您还需要判断用户手机是否支持 Custom Tabs。
配置属性:
CustomTabsIntent.Builder intentBuilder = new CustomTabsIntent.Builder(); // 修改 ActionBar 的颜色 intentBuilder.setToolbarColor(Color.RED); // 添加一个分享按钮 String shareLabel = "分享"; Bitmap icon = BitmapFactory.decodeResource(getResources(), android.R.drawable.ic_menu_share); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, new Intent(this, BlankActivity.class), 0); intentBuilder.setActionButton(icon, shareLabel, pendingIntent); //添加Menu 按钮 intentBuilder.addMenuItem("打开", pendingIntent); //是否显示网页标题 intentBuilder.setShowTitle(true); //隐藏网页Bar intentBuilder.enableUrlBarHiding(); //自定义关闭 Custom tabs 的图标 intentBuilder.setCloseButtonIcon(BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher)); //自定义 Activity 转场 动画 intentBuilder.setStartAnimations(this, R.anim.slide_in_right, R.anim.slide_out_left); intentBuilder.setExitAnimations(this, android.R.anim.slide_in_left, android.R.anim.slide_out_right); CustomTabsIntent customTabsIntent = intentBuilder.build();// customTabsIntent.launchUrl(this, Uri.parse("http://www.51offer.com/"));
0 0
- Chrome Custom Tabs
- Chrome Custom Tabs最佳实践
- 提升体验-支持Chrome Custom Tabs
- (4.1.49)提升体验-支持Chrome Custom Tabs
- Custom Android Tabs
- Android 开发小工具之:Custom Tabs
- Android 开发小工具之:Custom Tabs
- Custom Window Chrome in WPF
- chrome.tabs,与javascript同源策略
- chrome.tabs.onUpdated.addListener的应用
- chrome.tabs.getCurrent 返回 tab 是undefined?
- Steps to add Custom Tabs to the Product Admin
- 解决Chrome插件chrome.tabs无效的Bug
- chrome 33+ 使用 custom.css 设置字体
- Chrome 33+ 自建 扩展 实现 custom.css
- Tabs
- Tabs
- Tabs
- 数据库常见错误及解决办法
- 图片上下居中对齐 按比例
- git ignore files配置
- java 使用ExecutorService 建立多线程
- 关于屏幕dp和px
- Chrome Custom Tabs
- 蓝桥杯练习题 BASIC-19 完美的代价(贪心算法)
- 系统参数的设计,通用方法提取,页面处理map字符串并显示系统参数(增强版)
- 手把手教你将odex转dex
- ERROR [IM014] [Microsoft][ODBC 驱动程序管理器] 在指定的 DSN 中,驱动程序和应用程序之间的体系结构不匹配
- sqlite数据库基本操作
- 168. Excel Sheet Column Title [easy] (Python)
- Java NIO系列教程(一) Java NIO 概述
- WebView 实战