简体   繁体   English

AppBar 布局透明背景

[英]AppBar Layout Transparent Background

在此处输入图片说明

Codes:代码:

<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>

I want to delete the background seen in the image (under arc layout gray backgroundcolor).. The background color of every place did not transparently.我想删除图像中看到的背景(在弧形布局灰色背景色下)..每个地方的背景色都没有透明。 I want to use arc layout in my project or arc shape ETC.我想在我的项目中使用弧形布局或弧形 ETC。 I wrote all the codes above.. Also, How to draw a xml shape like arc layout?我写了上面的所有代码..另外,如何绘制像弧形布局这样的xml形状?

It doesn't try everything.它不会尝试一切。 Please help me请帮我

Thanks in advance..提前致谢..

Are you sure that the background color you're setting to the arclayout is transparent ?您确定为 arclayout 设置的背景颜色是透明的吗? These are the codes for color transparency.这些是颜色透明度的代码。 Put value in front of color value.将值放在颜色值之前。 Example :例子 :

FF FF2D00 FF FF2D00

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

 android:background="#00000000"

试试这个它对我有用。

Try to move your ArcLayout outside AppBarLayout like below:尝试移动您的ArcLayoutAppBarLayout象下面这样:

<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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM