【问题标题】:Custom reveal effect is showing below the WebView Android not revealing the web view自定义显示效果显示在 WebView Android 下方不显示 Web 视图
【发布时间】:2015-09-18 05:51:50
【问题描述】:

我正在使用 Circular Reveal Library (ttps://github.com/ozodrukh/CircularReveal) 在包含 Web 视图的活动中显示视图,此动画可以正常工作,但它在 Web 视图下方绘制。 WebView 不会随其父视图显示,当我向 WebView 添加一些动画时,这会取消循环显示动画。

<?xml version="1.0" encoding="utf-8"?>
<io.codetail.widget.RevealFrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <LinearLayout
        android:id="@+id/myLayout"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <android.support.v7.widget.CardView
            android:id="@+id/myCard"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:cardUseCompatPadding="true"
            app:contentPadding="5dp">

            <WebView
                android:id="@+id/myWeb"
                android:layout_width="match_parent"
                android:layout_height="wrap_content" />

        </android.support.v7.widget.CardView>

    </LinearLayout>

</io.codetail.widget.RevealFrameLayout>



<?xml version="1.0" encoding="utf-8"?>
<io.codetail.widget.RevealFrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <LinearLayout
        android:id="@+id/myLayout"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <android.support.v7.widget.CardView
            android:id="@+id/myCard"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:cardUseCompatPadding="true"
            app:contentPadding="5dp">

            <WebView
                android:id="@+id/myWeb"
                android:layout_width="match_parent"
                android:layout_height="wrap_content" />

        </android.support.v7.widget.CardView>

    </LinearLayout>

</io.codetail.widget.RevealFrameLayout>

【问题讨论】:

  • 我认为你复制了你的 xml。同一个 xml 中不能有两个根视图
  • 你试过将WebViewheight设置为match_parent
  • @Darpan 你找到解决方案了吗?

标签: android webview circularreveal


【解决方案1】:

一种可能的解决方法是使用 AnimatorListener 来切换 WebView 的可见性:

WebView webView = ...

Animator circularReveal = ViewAnimationUtils.createCircularReveal( ... )
circularReveal.addListener(new Animator.AnimatorListener() {

    @Override
    public void onAnimationStart(Animator animator) {
        webView.setVisibility(View.INVISIBLE)
    }

    @Override
    public void onAnimationEnd(Animator animator) {
        webView.setVisibility(View.VISIBLE)
    }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-11-26
    • 2016-11-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多