마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

액션바 투명하게 만들기 질문좀 드립니다.

0 추천

제가 현제 구현해야 하는 화면입니다.

액션바를 보시면 아래 배경과 동일한 색상처럼 보입니다. 동일한 색상으로 보이는 이유는 아마

배경에 투명도를 준것같은데요.

제가 구현하기전 화면입니다.

제가 구현후 화면입니다.

저는 여기서 앱바 레이아웃에 

android:background="@android:color/transparent"

속성을 줬습니다.

 

액션바가 구현되어있는 xml파일입니다.

Navigation Drawer 액티비티의 xml을 제가 수정한것입니다.

<androidx.drawerlayout.widget.DrawerLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:openDrawer="start">

    <androidx.coordinatorlayout.widget.CoordinatorLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        tools:context=".MovieList">
        <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:theme="@style/AppTheme.AppBarOverlay">
            <androidx.appcompat.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                app:popupTheme="@style/AppTheme.PopupOverlay" />
        </com.google.android.material.appbar.AppBarLayout>

        <fragment
            android:id="@+id/nav_host_fragment"
            android:name="androidx.navigation.fragment.NavHostFragment"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_constraintTop_toBottomOf="@id/appbar"
            app:layout_constraintLeft_toLeftOf="parent"
            app:layout_constraintRight_toRightOf="parent"
            app:defaultNavHost="true"
            app:navGraph="@navigation/mobile_navigation"/>
    </androidx.coordinatorlayout.widget.CoordinatorLayout>

    <com.google.android.material.navigation.NavigationView
        android:id="@+id/nav_view"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:fitsSystemWindows="true"
        app:headerLayout="@layout/nav_header_main"
        app:menu="@menu/activity_main_drawer" />
</androidx.drawerlayout.widget.DrawerLayout>

여기서 인터넷을 찾아봤을때는

app:elevation="0dp"

를 주면 된다고하던데..

AppbarLayout 태그에 elevation을 줬을경우 아무런 효과가 없었고

그 내부에 Toolbar 태그에 elevation을 줬을경우에는 

바로가기메뉴(햄버거 메뉴)의 영화목록이란 텍스트와 아이콘이 사라졌습니다.

 

어떻게하면 이 현상을 해결 할 수있을까요?

codeslave (3,940 포인트) 님이 2020년 10월 8일 질문
Theme을 아래처럼
<style name="YourAppTheme" parent="@android:style/Theme.AppCompat">
    <item name="windowActionBar">false</item>
    <item name="windowActionBarOverlay">true</item>
    <item name="android:windowActionBarOverlay">true</item>
</style>

Or

android:background="@null"
style.xml 파일에 선생님이 써주신거 그냥 그대로 붙이면 되는거 아닌가요?
parent부분이 아예 안되네요..
현재 님이 사용하는 theme이 뭔지 모르기 때문에 Theme.AppCompat을 쓴다고 가정한거구요. 님이 현재 쓰시는 parent theme을 넣어보세요.

1개의 답변

0 추천
액션바 백그라운드 색상을 투명으로하시면되죠
꿀개 (2,440 포인트) 님이 2020년 10월 8일 답변
백그라운드 #00000000해봤는데 안돼요..
...