学无止境-1


为了让自己不浑浑噩噩的看代码,抄代码,看解释,对每天的学习进度做一个总结,虽然不知道能坚持多久。

1. Custom Tabs
为了提高用户体验,在用app打开浏览器的时候,能够定制Chrome的外观和操作。

  1. 将 Custom Tabs Support Library 添加到工程中来
    dependencies {
    ...
    compile 'com.android.support:customtabs:23.3.0'
    }
  2. 打开一个Chrome Custom Tab
    使用CustomTabsIntent.Builder配置CustomTabsIntent
    准备完成后,调用CustomTabsIntent.Builder.build()方法创建一个CustomTabsIntent 并通过CustomTabsIntent.launchUrl()方法加载希望加载的url

    String url = ¨https://github.com/marktony¨;
    CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
    CustomTabsIntent customTabsIntent = builder.build();
    customTabsIntent.launchUrl(this, Uri.parse(url));

  3. 配置地址栏的颜色
    // 改变toolbar的背景色。colorInt就是想要指定的int值
    builder.setToolbarColor(colorInt);

  4. 配置定制化的action button
    // 向toolbar添加一个Action Button
    // ‘icon’是一张位图(Bitmap),作为action button的图片资源使用
    // 'description'是一个字符串,作为按钮的无障碍描述所使用
    // 'pendingIntent' 是一个PendingIntent,当action button或者菜单项被点击时调用。
    // 在url作为data被添加之后,Chrome 会调用PendingIntent#send()方法。
    // 客户端应用会通过调用Intent#getDataString()获取到URL
    // 'tint'是一个布尔值,定义了Action Button是否应该被着色
    builder.setActionButton(icon, description, pendingIntent, tint);


还没看完,明天继续。

http://blog.csdn.net/marktonylztl/article/details/54120245

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值