【问题标题】:AppBar Layout Transparent BackgroundAppBar 布局透明背景
【发布时间】:2019-12-05 18:26:16
【问题描述】:

代码:

<androidx.coordinatorlayout.widget.CoordinatorLayout 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">


    <com.google.android.material.appbar.AppBarLayout
        android:id="@+id/appBar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@android:color/transparent"
        android:backgroundTint="@android:color/transparent"
        android:fitsSystemWindows="true"
        app:layout_scrollFlags="scroll|enterAlwaysCollapsed">

        <com.google.android.material.appbar.CollapsingToolbarLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@android:color/transparent"
            android:backgroundTint="@android:color/transparent"
            app:contentScrim="?attr/colorPrimary"
            app:layout_scrollFlags="scroll|enterAlwaysCollapsed"
            app:titleEnabled="false">


            <androidx.appcompat.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                android:background="@color/colorPrimary"
                app:popupTheme="@style/AppTheme.PopupOverlay" />


        </com.google.android.material.appbar.CollapsingToolbarLayout>


        <com.github.florent37.arclayout.ArcLayout
            android:layout_width="match_parent"
            android:layout_height="90dp"
            android:background="@android:color/transparent"
            app:arc_cropDirection="cropOutside"
            app:arc_height="30dp"
            app:layout_behavior="@string/appbar_scrolling_view_behavior">


            <View
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="@color/colorPrimary" />
        </com.github.florent37.arclayout.ArcLayout>


    </com.google.android.material.appbar.AppBarLayout>


    <androidx.core.widget.NestedScrollView
        android:id="@+id/vkiscrollview"
        android:layout_width="match_parent"
        android:layout_height="604dp"
        android:background="@color/darkblue"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@color/transparent"
            android:visibility="gone"
            android:backgroundTint="@color/transparent">

                    CONTENT....



        </RelativeLayout>

    </androidx.core.widget.NestedScrollView>



</androidx.coordinatorlayout.widget.CoordinatorLayout>

我想删除图像中看到的背景(在弧形布局灰色背景色下).. 每个地方的背景颜色都不是透明的。 我想在我的项目或弧形 ETC 中使用弧形布局。上面所有的代码都是我写的。还有,如何绘制像弧形布局这样的xml形状?

它不会尝试一切。请帮帮我

提前谢谢..

【问题讨论】:

标签: java android


【解决方案1】:

您确定您为 arclayout 设置的背景颜色是透明的吗?这些是颜色透明度的代码。将值放在颜色值之前。示例:

FFFF2D00

100% — FF 95%——F2 90%——E6 85% — D9 80%——抄送 75% — 高炉 70% — B3 65%——A6 60% — 99 55% — 8℃ 50% — 80 45% — 73 40% — 66 35% — 59 30% — 4D 25% — 40 20% — 33 15% — 26 10% — 1A 5% — 0天 0% — 00

【讨论】:

    【解决方案2】:
     android:background="#00000000"
    

    试试这个它对我有用。

    【讨论】:

    • 不幸的是:(它不是
    【解决方案3】:

    尝试将您的ArcLayout 移到AppBarLayout 之外,如下所示:

    <androidx.coordinatorlayout.widget.CoordinatorLayout 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">
    
    
        <com.google.android.material.appbar.AppBarLayout
            android:id="@+id/appBar"
            app:elevation="0dp"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@android:color/transparent"
            android:backgroundTint="@android:color/transparent"
            android:fitsSystemWindows="true"
            app:layout_scrollFlags="scroll|enterAlwaysCollapsed">
    
            <com.google.android.material.appbar.CollapsingToolbarLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@android:color/transparent"
                android:backgroundTint="@android:color/transparent"
                app:contentScrim="?attr/colorPrimary"
                app:layout_scrollFlags="scroll|enterAlwaysCollapsed"
                app:titleEnabled="false">
    
    
                <androidx.appcompat.widget.Toolbar
                    android:id="@+id/toolbar"
                    android:layout_width="match_parent"
                    android:layout_height="?attr/actionBarSize"
                    android:background="@color/colorPrimary"
                    app:popupTheme="@style/AppTheme.PopupOverlay" />
    
    
            </com.google.android.material.appbar.CollapsingToolbarLayout>
    
        </com.google.android.material.appbar.AppBarLayout>
    
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical"
            app:layout_behavior="@string/appbar_scrolling_view_behavior" >
    
            <com.github.florent37.arclayout.ArcLayout
                android:layout_width="match_parent"
                android:layout_height="90dp"
                android:background="@android:color/transparent"
                app:arc_cropDirection="cropOutside"
                app:arc_height="30dp">
    
    
                <View
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:background="@color/colorPrimary" />
            </com.github.florent37.arclayout.ArcLayout>
    
            <androidx.core.widget.NestedScrollView
                android:id="@+id/vkiscrollview"
                android:layout_width="match_parent"
                android:layout_height="604dp"
                android:background="@color/darkblue">
    
                <RelativeLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:background="@color/transparent"
                    android:visibility="gone"
                    android:backgroundTint="@color/transparent">
    
                </RelativeLayout>
    
            </androidx.core.widget.NestedScrollView>
        </LinearLayout>
    
    </androidx.coordinatorlayout.widget.CoordinatorLayout>
    

    【讨论】:

    • 不幸的是 :( 没有再次工作。在 arcview 中,外面是灰色背景。如何在 90 dp 高度制作类似 arcview 的形状?
    • 就我而言,我没有看到灰色条
    • 嘿,我在AppBarLayout 中设置了app:elevation="0dp"。可能你错过了
    • 用我的layout 替换并检查
    • 截图; ibb.co/bBw59xv你说的我都做了。 (滚动前和滚动后)它不工作
    猜你喜欢
    • 2023-03-02
    • 1970-01-01
    • 2023-03-16
    • 2012-11-01
    • 2020-03-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多