gpt4 book ai didi

Android:如何像 YouTube 在他的应用程序中那样创建 WebView

转载 作者:太空狗 更新时间:2023-10-29 15:50:46 25 4
gpt4 key购买 nike

YouTube 应用:在任何 channel 的“about”选项卡中,都有该 channel 的一些社交网站链接。我访问了一些链接并检查了链接是否在 WebView 中打开。这是屏幕截图:

enter image description here

WebView 似乎与普通的 WebView 不同。它像 Chrome 一样包含地址栏和溢出菜单。

  1. 是否在 WebView Activity 中为地址栏和 Overflow 菜单 添加了 EditText

  2. 他们是否在使用任何库,因为它也写成“由 Chrome 提供支持?”

最佳答案

他们使用 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

关于Android:如何像 YouTube 在他的应用程序中那样创建 WebView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40772225/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com