工具栏没有出现在pre棒棒糖设备 [英] toolbar not appearing in pre lollipop devices

查看:246
本文介绍了工具栏没有出现在pre棒棒糖设备的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

工具栏未出现在pre棒棒糖设备。我使用的抽屉布局工具栏。相同的工具栏与其他的活动,但不带抽屉布局一起使用时。

活动抽屉布局和工具栏

  @覆盖
        保护无效的onCreate(捆绑savedInstanceState){
            super.onCreate(savedInstanceState);
              的setContentView(R.layout.activity_home_screen);                {                    / * supportChatImageButton =(的ImageButton)findViewById(R.id.homeSupportChatImageButton);
                    orderImageButton =(的ImageButton)findViewById(R.id.homeOrderImageButton); * /
                    headerTextView =(的TextView)findViewById(R.id.homeHeaderTextView);
                    slidingTabLayout =(SlidingTabLayout)findViewById(R.id.homeSlidingTabLayout);
                    viewPager =(ViewPager)findViewById(R.id.homeViewPager);
                    headerBackgroundImageView =(ImageView的)findViewById(R.id.homeHeaderBackgroundImageView);                    mainContentLayout =(的FrameLayout)findViewById(R.id.homeScreenMainContentLayout);
                    hamburgerLayout =(DrawerLayout)findViewById(R.id.drawer_layout);
                    hamburgerLinearLayout =(的LinearLayout)findViewById(R.id.hamburgerProfileLayout);
                    hamburgerListView =(ListView控件)findViewById(R.id.hamburgerListView);
                    hamburgerMenu =(RelativeLayout的)findViewById(R.id.hamburgerMenu);
                    GetHamburgerListItems();
                    HamburgerListAdapter hamburgerListAdapter =新HamburgerListAdapter(这一点,hamburgerListItems);
                    hamburgerListView.setAdapter(hamburgerListAdapter);                    userProfileImageView =(ImageView的)findViewById(R.id.userProfileImageView);
                    userProfileNameTextView =(的TextView)findViewById(R.id.userProfileNameTextView);                    如果(StorageManager.read(在此,USERPROFILE,新TypeToken&下;用户配置>(){} .getType())!= NULL){
                        用户配置USERPROFILE =(用户配置)StorageManager.read(这一点,用户配置,新TypeToken<用户配置>(){} .getType());
                        userProfileNameTextView.setText(userProfile.getFullName());
                    }
                    其他{
                        userProfileNameTextView.setText(登录/注册);
                    }                    字体字型= Typeface.createFromAsset(this.getAssets(),字体/ GothamRnd-Medium.otf);
                    slidingTabLayout.setTypeface(字体);
                    slidingTabLayout.setTextColor(#FFFFFF);
                }                如果(Utilities.IsCitySelected(本)){
                    selectedCity = Utilities.GetSelectedCity(本);
                }
                其他{
                    意向意图=新意图(HomeScreenActivity.this,ErrorInternetActivity.class);
                    intent.putExtra(错误,错误);
                    startActivity(意向);
                    完();
                }
                工具栏=(栏)findViewById(R.id.main_toolbar);
                toolbar.setNavigationIcon(R.drawable.ic_action_image_dehaze);
                toolbar.inflateMenu(R.menu.home_screen_menu);
                toolbar.setBackgroundColor(Color.TRANSPARENT);
                setSupportActionBar(工具栏);
                getSupportActionBar()setDisplayShowHomeEnabled(真)。
                getSupportActionBar()setDisplayShowTitleEnabled(假)。
                getSupportActionBar()setDisplayHomeAsUpEnabled(真)。                actionBarDrawerToggle =新ActionBarDrawerToggle(这一点,hamburgerLayout,工具栏,R.string.drawer_open,R.string.drawer_close){
                    @覆盖
                    公共无效onDrawerOpened(查看drawerView){
                        super.onDrawerOpened(drawerView);
                        invalidateOptionsMenu();
                        syncState();
                    }                    @覆盖
                    公共无效onDrawerClosed(查看drawerView){
                        super.onDrawerClosed(drawerView);
                        invalidateOptionsMenu();
                        syncState();
                    }
                };                hamburgerLayout.setDrawerListener(actionBarDrawerToggle);
                hamburgerLayout.setDrawerListener(本);        hamburgerListView.setOnItemClickListener(新AdapterView.OnItemClickListener(){
                    @覆盖
                    公共区域    IC无效onItemClick(适配器视图<>母公司,观景,最终诠释的位置,长的id){
                    SelectItemFromDrawer(位置);
                }
            });            hamburgerLinearLayout.setOnClickListener(新View.OnClickListener(){
                @覆盖
                公共无效的onClick(视图v){                    如果(Utilities.IsUserLoggedIn(HomeScreenActivity.this)){
                        hamburgerLayout.closeDrawer(hamburgerMenu);
                        isLinkClicked = TRUE;
                        位置= 2;
                    }
                    其他{
                        hamburgerLayout.closeDrawer(hamburgerMenu);
                        isLinkClicked = TRUE;
                        位置= 3;
                    }
}                }
            });

活动 - XML

 <?XML版本=1.0编码=UTF-8&GT?;
< android.support.v4.widget.DrawerLayout
    的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    的xmlns:工具=htt​​p://schemas.android.com/tool​​s
    的xmlns:程序=htt​​p://schemas.android.com/apk/res-auto
    机器人:ID =@ + ID / drawer_layout
    机器人:layout_width =match_parent
    机器人:layout_height =match_parent
    工具:上下文=HomeScreenActivity。>    <的FrameLayout
        机器人:ID =@ + ID / homeScreenMainContentLayout
        机器人:layout_width =match_parent
        机器人:layout_height =match_parent
        机器人:方向=垂直>        <包括
            布局=@布局/ main_toolbar/>        <的LinearLayout
            机器人:layout_width =match_parent
            机器人:layout_height =match_parent
            机器人:方向=垂直>            <的LinearLayout
                机器人:layout_width =match_parent
                机器人:layout_height =match_parent
                机器人:layout_weight =0.6>                <的FrameLayout
                    机器人:layout_width =match_parent
                    机器人:layout_height =match_parent>                    < ImageView的
                        机器人:ID =@ + ID / homeHeaderBackgroundImageView
                        机器人:layout_width =match_parent
                        机器人:layout_height =match_parent
                        机器人:scaleType =fitXY/>                    < RelativeLayout的
                        机器人:layout_width =match_parent
                        机器人:layout_height =match_parent>                        <的LinearLayout
                            机器人:layout_width =match_parent
                            机器人:layout_height =42dp
                            机器人:layout_alignParentTop =真
                            机器人:layout_marginTop =12dp
                            机器人:重力=右>                            <! - <的ImageButton
                                机器人:ID =@ + ID / homeSupportChatImageButton
                                机器人:layout_width =36dp
                                机器人:layout_height =36dp
                                机器人:layout_marginRight =20dp
                                机器人:背景=@绘制/ ic_help
                                机器人:知名度=看得见/>                            <的ImageButton
                                机器人:ID =@ + ID / homeOrderImageButton
                                机器人:layout_width =36dp
                                机器人:layout_height =36dp
                                机器人:layout_marginRight =16DP
                                机器人:背景=@绘制/ ic_menu_orders/> - >                        < / LinearLayout中>                        < com.localoye.mobileapp.misc.LocaloyeTextView
                            机器人:ID =@ + ID / homeHeaderTextView
                            机器人:layout_width =match_parent
                            机器人:layout_height =WRAP_CONTENT
                            机器人:layout_centerInParent =真
                            机器人:比重=中心
                            机器人:文字=@字符串/ home_screen_header_text
                            机器人:文字颜色=@色/白
                            机器人:TEXTSIZE =24sp
                            机器人:文字样式=大胆
                            应用:的fontName =@字符串/ gotha​​m_bold_reg/>                        < com.localoye.mobileapp.misc.SlidingTabLayout
                            机器人:ID =@ + ID / homeSlidingTabLayout
                            字体路径=字体/ GothamRnd-Medium.otf
                            机器人:layout_width =match_parent
                            机器人:layout_height =WRAP_CONTENT
                            机器人:layout_alignParentBottom =真
                            机器人:paddingTop =10dp>< /com.localoye.mobileapp.misc.SlidingTabLayout>                    < / RelativeLayout的>                < /&的FrameLayout GT;            < / LinearLayout中>            <的LinearLayout
                机器人:layout_width =match_parent
                机器人:layout_height =match_parent
                机器人:layout_weight =0.40
                机器人:背景=#FFFFFF>                < android.support.v4.view.ViewPager
                    机器人:ID =@ + ID / homeViewPager
                    机器人:layout_width =match_parent
                    机器人:layout_height =match_parent
                    机器人:背景=#FFFFFF>< /android.support.v4.view.ViewPager>            < / LinearLayout中>        < / LinearLayout中>    < /&的FrameLayout GT;    <! - 导航抽屉 - >
    < RelativeLayout的
        机器人:ID =@ + ID / hamburgerMenu
        机器人:layout_width =280dp
        机器人:layout_height =match_parent
        机器人:layout_gravity =开始>        <! - 档案盒 - >        <的LinearLayout
            机器人:ID =@ + ID / hamburgerProfileLayout
            机器人:layout_width =match_parent
            机器人:layout_height =144dp
            机器人:背景=@彩色/ lo_orange
            机器人:重力=center_vertical
            机器人:方向=垂直>            < ImageView的
                机器人:ID =@ + ID / userProfileImageView
                机器人:layout_width =56dp
                机器人:layout_height =56dp
                机器人:layout_marginLeft =16DP
                机器人:scaleType =fitXY
                机器人:SRC =@绘制/ ic_person_blue/>            < com.localoye.mobileapp.misc.LocaloyeTextView
                机器人:ID =@ + ID / userProfileNameTextView
                机器人:layout_width =match_parent
                机器人:layout_height =WRAP_CONTENT
                机器人:layout_marginTop =8DP
                机器人:layout_marginLeft =16DP
                应用:的fontName =@字符串/ gotha​​m_medium_reg
                机器人:TEXTSIZE =14sp
                机器人:文字=
                机器人:文字颜色=#FFFFFF/>        < / LinearLayout中>        <! - 行动(页)的列表 - >
        < ListView控件
            机器人:ID =@ + ID / hamburgerListView
            机器人:layout_width =280dp
            机器人:layout_height =match_parent
            机器人:layout_below =@ ID / hamburgerProfileLayout
            机器人:背景=#FFFFFF
            机器人:choiceMode =singleChoice/>    < / RelativeLayout的>< /android.support.v4.widget.DrawerLayout>

main_toolbar.xml

 <?XML版本=1.0编码=UTF-8&GT?;
< android.support.v7.widget.Toolbar
    的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    的xmlns:程序=htt​​p://schemas.android.com/apk/res-auto
    机器人:ID =@ + ID / main_toolbar
    机器人:layout_width =match_parent
    机器人:layout_height =WRAP_CONTENT
    机器人:背景=@彩色/ lo_orange
    安卓了minHeight =?ATTR / actionBarSize
    机器人:fitsSystemWindows =真
    应用:主题=@风格/ ThemeOverlay.AppCompat.Dark.ActionBar
    应用:popupTheme =@风格/ ThemeOverlay.AppCompat.Light
    机器人:海拔=4DP>    <的LinearLayout
        机器人:layout_width =match_parent
        机器人:layout_height =WRAP_CONTENT
        机器人:方向=垂直>        < com.localoye.mobileapp.misc.LocaloyeTextView
            机器人:ID =@ + ID / toolBarTitleTextView
            机器人:layout_width =WRAP_CONTENT
            机器人:layout_height =WRAP_CONTENT
            应用:的fontName =@字符串/ gotha​​m_medium_reg
            机器人:MAXLINES =2
            机器人:TEXTSIZE =16SP
            机器人:文字颜色=#FFFFFF/>        < com.localoye.mobileapp.misc.LocaloyeTextView
            机器人:ID =@ + ID / toolBarSubTitleTextView
            机器人:layout_width =match_parent
            机器人:layout_height =WRAP_CONTENT
            应用:的fontName =@字符串/ gotha​​m_light_reg
            机器人:MAXLINES =1
            机器人:TEXTSIZE =12SP
            机器人:知名度=水涨船高
            机器人:文字颜色=#FFFFFF/>    < / LinearLayout中>< /android.support.v7.widget.Toolbar>

style.xml

 <! -  Base应用程序的主题。 - >
    <样式名称=AppTheme父=Theme.AppCompat.Light.NoActionBar>
        <! - 在这里自定义的主题。 - >
        <项目名称=机器人:textColorHintInverse> @彩色/ lo_orange< /项目>
        <! - <项目名称=colorPrimaryDark> @彩色/ dark_orange< /项目> - >
        <项目名称=colorPrimary> @彩色/ lo_orange< /项目>
        <项目名称=colorAccent> @彩色/ lo_orange< /项目>        <! - 14 API自定义主题可以去这里。 - >
        <项目名称=机器人:windowActionBarOverlay>真< /项目>        <! - 支持库的兼容性 - >
        <项目名称=windowActionBarOverlay>真< /项目>        <项目名称=机器人:windowNoTitle>真< /项目>
        <项目名称=机器人:windowActionBar>假LT; /项目>        <项目名称=windowNoTitle>真< /项目>
        <项目名称=windowActionBar>假LT; /项目>    < /风格>


解决方案

这是一个常见的​​问题变得不那么明显的棒棒糖测试或更高版本时。

在使用标准布局(如的FrameLayout RelativeLayout的等)的默认行为是孩子的意见得到为了将它们添加或充气绘制。

该修补程序将类似于这样:

 <&的FrameLayout GT;
     <! - 内容将首先被吸引 - 工具栏下方。 - >
     <的FrameLayout机器人:ID =@ + ID / main_content/>
     <! - 工具栏将在下面画 - 内容上面。 - >
     < android.support.v7.widget.Toolbar机器人:ID =@ + ID /工具栏/>
< /&的FrameLayout GT;

不过,由于棒棒堂的android:海拔属性可以覆盖这个行为。由于海拔定义随着海拔较高值,Z轴的看法precise位置将高于那些低高程值绘制。

Toolbar is not appearing on pre lollipop devices. I'm using drawer layout with toolbar. The same toolbar works on other activities but not when used along with drawer layout.

Activity with drawer layout and toolbar

@Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);


              setContentView(R.layout.activity_home_screen);

                {

                    /*supportChatImageButton = (ImageButton) findViewById(R.id.homeSupportChatImageButton);
                    orderImageButton = (ImageButton) findViewById(R.id.homeOrderImageButton);*/
                    headerTextView = (TextView) findViewById(R.id.homeHeaderTextView);
                    slidingTabLayout = (SlidingTabLayout) findViewById(R.id.homeSlidingTabLayout);
                    viewPager = (ViewPager) findViewById(R.id.homeViewPager);
                    headerBackgroundImageView = (ImageView)findViewById(R.id.homeHeaderBackgroundImageView);

                    mainContentLayout = (FrameLayout) findViewById(R.id.homeScreenMainContentLayout);
                    hamburgerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
                    hamburgerLinearLayout = (LinearLayout) findViewById(R.id.hamburgerProfileLayout);
                    hamburgerListView = (ListView) findViewById(R.id.hamburgerListView);
                    hamburgerMenu = (RelativeLayout) findViewById(R.id.hamburgerMenu);
                    GetHamburgerListItems();
                    HamburgerListAdapter hamburgerListAdapter = new HamburgerListAdapter(this, hamburgerListItems);
                    hamburgerListView.setAdapter(hamburgerListAdapter);

                    userProfileImageView = (ImageView) findViewById(R.id.userProfileImageView);
                    userProfileNameTextView = (TextView) findViewById(R.id.userProfileNameTextView);

                    if(StorageManager.read(this, "userProfile", new TypeToken<UserProfile>() {}.getType()) != null) {
                        UserProfile userProfile = (UserProfile) StorageManager.read(this, "userProfile", new TypeToken<UserProfile>() {}.getType());
                        userProfileNameTextView.setText(userProfile.getFullName());
                    }
                    else {
                        userProfileNameTextView.setText("Login / Sign up");
                    }

                    Typeface typeface = Typeface.createFromAsset(this.getAssets(), "fonts/GothamRnd-Medium.otf");
                    slidingTabLayout.setTypeface(typeface);
                    slidingTabLayout.setTextColor("#FFFFFF");
                }

                if(Utilities.IsCitySelected(this)) {
                    selectedCity = Utilities.GetSelectedCity(this);
                }
                else {
                    Intent intent = new Intent(HomeScreenActivity.this, ErrorInternetActivity.class);
                    intent.putExtra("error", "error");
                    startActivity(intent);
                    finish();
                }


                toolbar = (Toolbar) findViewById(R.id.main_toolbar);
                toolbar.setNavigationIcon(R.drawable.ic_action_image_dehaze);
                toolbar.inflateMenu(R.menu.home_screen_menu);
                toolbar.setBackgroundColor(Color.TRANSPARENT);
                setSupportActionBar(toolbar);
                getSupportActionBar().setDisplayShowHomeEnabled(true);
                getSupportActionBar().setDisplayShowTitleEnabled(false);
                getSupportActionBar().setDisplayHomeAsUpEnabled(true);

                actionBarDrawerToggle = new ActionBarDrawerToggle(this, hamburgerLayout, toolbar, R.string.drawer_open, R.string.drawer_close) {
                    @Override
                    public void onDrawerOpened(View drawerView) {
                        super.onDrawerOpened(drawerView);
                        invalidateOptionsMenu();
                        syncState();
                    }

                    @Override
                    public void onDrawerClosed(View drawerView) {
                        super.onDrawerClosed(drawerView);
                        invalidateOptionsMenu();
                        syncState();
                    }
                };

                hamburgerLayout.setDrawerListener(actionBarDrawerToggle);
                hamburgerLayout.setDrawerListener(this);

        hamburgerListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                    @Override
                    publ

    ic void onItemClick(AdapterView<?> parent, View view, final int position, long id) {
                    SelectItemFromDrawer(position);
                }
            });

            hamburgerLinearLayout.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {

                    if(Utilities.IsUserLoggedIn(HomeScreenActivity.this)) {
                        hamburgerLayout.closeDrawer(hamburgerMenu);
                        isLinkClicked = true;
                        position = 2;
                    }
                    else {
                        hamburgerLayout.closeDrawer(hamburgerMenu);
                        isLinkClicked = true;
                        position = 3;
                    }
}

                }
            });

Activity - XML

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".HomeScreenActivity">

    <FrameLayout
        android:id="@+id/homeScreenMainContentLayout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <include
            layout="@layout/main_toolbar"/>

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

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="0.6">

                <FrameLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent">

                    <ImageView
                        android:id="@+id/homeHeaderBackgroundImageView"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:scaleType="fitXY" />

                    <RelativeLayout
                        android:layout_width="match_parent"
                        android:layout_height="match_parent">

                        <LinearLayout
                            android:layout_width="match_parent"
                            android:layout_height="42dp"
                            android:layout_alignParentTop="true"
                            android:layout_marginTop="12dp"
                            android:gravity="right">

                            <!--<ImageButton
                                android:id="@+id/homeSupportChatImageButton"
                                android:layout_width="36dp"
                                android:layout_height="36dp"
                                android:layout_marginRight="20dp"
                                android:background="@drawable/ic_help"
                                android:visibility="visible" />

                            <ImageButton
                                android:id="@+id/homeOrderImageButton"
                                android:layout_width="36dp"
                                android:layout_height="36dp"
                                android:layout_marginRight="16dp"
                                android:background="@drawable/ic_menu_orders" />-->

                        </LinearLayout>

                        <com.localoye.mobileapp.misc.LocaloyeTextView
                            android:id="@+id/homeHeaderTextView"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_centerInParent="true"
                            android:gravity="center"
                            android:text="@string/home_screen_header_text"
                            android:textColor="@color/white"
                            android:textSize="24sp"
                            android:textStyle="bold"
                            app:fontName="@string/gotham_bold_reg" />

                        <com.localoye.mobileapp.misc.SlidingTabLayout
                            android:id="@+id/homeSlidingTabLayout"
                            fontPath="fonts/GothamRnd-Medium.otf"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_alignParentBottom="true"
                            android:paddingTop="10dp"></com.localoye.mobileapp.misc.SlidingTabLayout>

                    </RelativeLayout>

                </FrameLayout>

            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="0.40"
                android:background="#FFFFFF">

                <android.support.v4.view.ViewPager
                    android:id="@+id/homeViewPager"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:background="#FFFFFF"></android.support.v4.view.ViewPager>

            </LinearLayout>

        </LinearLayout>

    </FrameLayout>

    <!-- The navigation drawer -->
    <RelativeLayout
        android:id="@+id/hamburgerMenu"
        android:layout_width="280dp"
        android:layout_height="match_parent"
        android:layout_gravity="start">

        <!-- Profile Box -->

        <LinearLayout
            android:id="@+id/hamburgerProfileLayout"
            android:layout_width="match_parent"
            android:layout_height="144dp"
            android:background="@color/lo_orange"
            android:gravity="center_vertical"
            android:orientation="vertical">

            <ImageView
                android:id="@+id/userProfileImageView"
                android:layout_width="56dp"
                android:layout_height="56dp"
                android:layout_marginLeft="16dp"
                android:scaleType="fitXY"
                android:src="@drawable/ic_person_blue" />

            <com.localoye.mobileapp.misc.LocaloyeTextView
                android:id="@+id/userProfileNameTextView"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="8dp"
                android:layout_marginLeft="16dp"
                app:fontName="@string/gotham_medium_reg"
                android:textSize="14sp"
                android:text=""
                android:textColor="#FFFFFF"/>

        </LinearLayout>

        <!-- List of Actions (pages) -->
        <ListView
            android:id="@+id/hamburgerListView"
            android:layout_width="280dp"
            android:layout_height="match_parent"
            android:layout_below="@id/hamburgerProfileLayout"
            android:background="#FFFFFF"
            android:choiceMode="singleChoice" />

    </RelativeLayout>

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

main_toolbar.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/main_toolbar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@color/lo_orange"
    android:minHeight="?attr/actionBarSize"
    android:fitsSystemWindows="true"
    app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
    app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
    android:elevation="4dp">

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

        <com.localoye.mobileapp.misc.LocaloyeTextView
            android:id="@+id/toolBarTitleTextView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            app:fontName="@string/gotham_medium_reg"
            android:maxLines="2"
            android:textSize="16sp"
            android:textColor="#FFFFFF"/>

        <com.localoye.mobileapp.misc.LocaloyeTextView
            android:id="@+id/toolBarSubTitleTextView"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:fontName="@string/gotham_light_reg"
            android:maxLines="1"
            android:textSize="12sp"
            android:visibility="gone"
            android:textColor="#FFFFFF"/>

    </LinearLayout>

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

style.xml

<!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <!-- Customize your theme here. -->
        <item name="android:textColorHintInverse">@color/lo_orange</item>
        <!--<item name="colorPrimaryDark">@color/dark_orange</item>-->
        <item name="colorPrimary">@color/lo_orange</item>
        <item name="colorAccent">@color/lo_orange</item>

        <!-- API 14 theme customizations can go here. -->
        <item name="android:windowActionBarOverlay">true</item>

        <!-- Support library compatibility -->
        <item name="windowActionBarOverlay">true</item>

        <item name="android:windowNoTitle">true</item>
        <item name="android:windowActionBar">false</item>

        <item name="windowNoTitle">true</item>
        <item name="windowActionBar">false</item>

    </style>

解决方案

This is a common issue becoming less apparent when testing on Lollipop or later.

When using standard layouts (such as FrameLayout, RelativeLayout etc.) the default behavior is that child views get drawn in order they are added or inflated.

The fix would look similar to this:

<FrameLayout>
     <!-- Content will be drawn first - below the toolbar. -->
     <FrameLayout android:id="@+id/main_content" />
     <!-- Toolbar will be drawn next - above the content. -->
     <android.support.v7.widget.Toolbar android:id="@+id/toolbar" />
</FrameLayout>

However since Lollipop the android:elevation attribute can override this behavior. Since elevation defines precise position along the Z axis views with higher elevation values will be drawn above those with lower elevation values.

这篇关于工具栏没有出现在pre棒棒糖设备的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆