透明工具栏,菜单图标和标题不起作用

时间:2018-06-09 07:48:08

标签: android android-actionbar android-navigation-drawer

我的标题栏如下所示:

image 1

我正试图让它透明,只获取导航图标&将全屏幕映射到地图视图中,但每次我尝试使用透明代码使条形图透明时,它最终会显示白色。

我也尝试了NoAction栏,但它仍然显示了一个白色的标题栏。

Home_activity.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent"
android:scrollbars="horizontal">

<RelativeLayout
    android:id="@+id/main"
    android:layout_width="match_parent"
    android:layout_height="match_parent">


    <android.support.v4.widget.DrawerLayout 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:background="@android:color/transparent"
        tools:openDrawer="start">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                android:layout_gravity="center"
                android:background="@android:color/transparent"
                android:fitsSystemWindows="true"
                app:popupTheme="@style/Theme.AppCompat.NoActionBar">

            </android.support.v7.widget.Toolbar>
            <!-- The first child in the layout is for the main Activity UI-->
            <FrameLayout
                android:id="@+id/frame"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_alignTop="@+id/drawer_layout"

                android:scrollbars="horizontal"
                app:layout_behavior="@string/appbar_scrolling_view_behavior">

                <ImageView
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                />

            </FrameLayout>
        </LinearLayout>

        <!-- Side navigation drawer UI -->

        <android.support.design.widget.NavigationView
            android:id="@+id/nav_view"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_gravity="start"
            app:headerLayout="@layout/navigation_header"
            app:itemBackground="@drawable/naviagtionview_statecolor"
            app:itemIconTint="@color/black"
            app:itemTextColor="@color/black"
            app:menu="@menu/my_navigation_items">

        </android.support.design.widget.NavigationView>


    </android.support.v4.widget.DrawerLayout>
</RelativeLayout>

style.xml

<resources xmlns:tools="http://schemas.android.com/tools">

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/hint</item>
    <item name="drawerArrowStyle">@style/MyDrawerArrowToggle</item>
    <item name="colorPrimaryDark">@color/hint</item>
    <item name="colorAccent">@color/black</item>
    <item name="actionBarStyle">@style/MyTheme.ActionBar.TitleTextStyle</item>




</style>
<style name="MyTheme.ActionBar" parent="android:Widget.Holo.ActionBar">
    <item name="android:background">@android:color/transparent</item>
    <item name="android:backgroundStacked">@android:color/transparent</item>
    <item name="android:displayOptions">showTitle</item>
    <item name="android:titleTextStyle">@style/MyTheme.ActionBar.TitleTextStyle</item>
</style>
<style name="AppTheme.NoActionBar" parent="Theme.AppCompat.Light.NoActionBar">
    <!-- Customize your theme here. -->
    <item name="drawerArrowStyle">@style/MyDrawerArrowToggle</item>



</style>

<style name="MyTheme.ActionBar.TitleTextStyle" parent="@android:style/TextAppearance">
    <item name="android:textColor">@color/black</item>

</style>

<style name="MyDrawerArrowToggle" parent="Widget.AppCompat.DrawerArrowToggle">
    <item name="color">@color/black</item>

</style>

<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />



<style name="EditText.Login" parent="Widget.AppCompat.EditText">
    <item name="android:textColor">@android:color/black</item>
    <item name="android:textColorHint">@android:color/darker_gray</item>
    <item name="colorAccent">@color/yellow</item>
    <item name="colorControlNormal">@color/black</item>
    <item name="colorControlActivated">@color/yellow</item>
</style>

但它显示如下:

image 2

1 个答案:

答案 0 :(得分:0)

我有类似的问题, 我用不同的方式来实现它, 您可以尝试this制作工具栏transperent。