Android: 如何像 YouTube 在他的应用中那样创建 WebView
Android: How to create WebView like YouTube has in his app
YouTube 应用程序: 在任何频道的“关于”选项卡中,都有该频道的一些社交网站链接。我访问了一些链接并检查了链接是否在 WebView 中打开。这是屏幕截图:
WebView 似乎与普通WebView 不同。它包含地址栏和溢出菜单,如 Chrome.
是否在地址栏中添加了EditText
和在WebView
中添加了Overflow menu
activity?
他们是否在使用任何库,因为它也是由 Chrome 提供支持的?
使用已有的功能自己制作它并不困难,但我相信 webview 基于 Chromium (WebView Chromium)
如您所知,chrome 是 Chromium 项目的代币
他们使用 Chrome 自定义标签
What are Chrome Custom Tabs?
App developers face a choice when a user taps a URL to either launch a
browser, or build their own in-app browser using WebViews.
Both options present challenges — launching the browser is a heavy
context switch that isn't customizable, while WebViews don't share
state with the browser and add maintenance overhead.
Chrome Custom Tabs give apps more control over their web experience,
and make transitions between native and web content more seamless
without having to resort to a WebView.
Chrome Custom Tabs allow an app to customize how Chrome looks and
feels. An app can change things like:
- Toolbar color
- Enter and exit animations
- Add custom actions to the Chrome toolbar, overflow menu and bottom toolbar
它在支持库中可用:
dependencies {
...
compile 'com.android.support:customtabs:23.3.0'
}
用法:
String url = ¨https://google.com/¨;
CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
CustomTabsIntent customTabsIntent = builder.build();
customTabsIntent.launchUrl(this, Uri.parse(url));
查看更多信息here
YouTube 应用程序: 在任何频道的“关于”选项卡中,都有该频道的一些社交网站链接。我访问了一些链接并检查了链接是否在 WebView 中打开。这是屏幕截图:
WebView 似乎与普通WebView 不同。它包含地址栏和溢出菜单,如 Chrome.
是否在地址栏中添加了
EditText
和在WebView
中添加了Overflow menu
activity?他们是否在使用任何库,因为它也是由 Chrome 提供支持的?
使用已有的功能自己制作它并不困难,但我相信 webview 基于 Chromium (WebView Chromium)
如您所知,chrome 是 Chromium 项目的代币
他们使用 Chrome 自定义标签
What are Chrome Custom Tabs?
App developers face a choice when a user taps a URL to either launch a browser, or build their own in-app browser using WebViews.
Both options present challenges — launching the browser is a heavy context switch that isn't customizable, while WebViews don't share state with the browser and add maintenance overhead.
Chrome Custom Tabs give apps more control over their web experience, and make transitions between native and web content more seamless without having to resort to a WebView.
Chrome Custom Tabs allow an app to customize how Chrome looks and feels. An app can change things like:
- Toolbar color
- Enter and exit animations
- Add custom actions to the Chrome toolbar, overflow menu and bottom toolbar
它在支持库中可用:
dependencies {
...
compile 'com.android.support:customtabs:23.3.0'
}
用法:
String url = ¨https://google.com/¨;
CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
CustomTabsIntent customTabsIntent = builder.build();
customTabsIntent.launchUrl(this, Uri.parse(url));
查看更多信息here