Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/220.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 工具栏下方显示的应用程序名称_Android_Xml - Fatal编程技术网

Android 工具栏下方显示的应用程序名称

Android 工具栏下方显示的应用程序名称,android,xml,Android,Xml,我的应用程序名Zenica没有出现在我的工具栏中,而是出现在工具栏下方。作为参考,我附上它的图像。此外,我希望保持工具栏的颜色与窗口的其他部分不同,但在toolbar.xml中设置背景时,整个窗口的颜色会发生更改,而不是仅更改工具栏的颜色 HomeActivity.java package com.zenica.app.zenica; import android.annotation.TargetApi; import android.os.Build; import android.os

我的应用程序名Zenica没有出现在我的工具栏中,而是出现在工具栏下方。作为参考,我附上它的图像。此外,我希望保持工具栏的颜色与窗口的其他部分不同,但在toolbar.xml中设置背景时,整个窗口的颜色会发生更改,而不是仅更改工具栏的颜色

HomeActivity.java

package com.zenica.app.zenica;

import android.annotation.TargetApi;
import android.os.Build;
import android.os.Bundle;
import android.support.design.widget.NavigationView;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.transition.Slide;
import android.transition.Transition;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.Window;

/**
 * Created by Neha on 03-02-2016.
 */
public class HomeActivity extends AppCompatActivity {

private Toolbar mtoolar;
DrawerLayout dLayout;
private NavigationView navView;
private ActionBarDrawerToggle mDrawerToggle;

@TargetApi(21)
@Override
public void onCreate(Bundle savedInstanceState) {
    int currentapiVersion = Build.VERSION.SDK_INT;
    if (currentapiVersion == Build.VERSION_CODES.LOLLIPOP) {
        getWindow().requestFeature(Window.FEATURE_CONTENT_TRANSITIONS);
        super.onCreate(savedInstanceState);
        Transition ts = new Slide();
        ts.setDuration(3000);
        getWindow().setEnterTransition(ts);
        getWindow().setExitTransition(ts);
        setContentView(R.layout.navigation_drawer);
    } else {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.navigation_drawer);
    }
    setToolbar();
    setNavigationDrawer();
}

private void setToolbar()
{
    mtoolar=(Toolbar) findViewById(R.id.tool_bar);
    dLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    setSupportActionBar(mtoolar);
    getSupportActionBar().setHomeButtonEnabled(true);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setElevation(5);
    mDrawerToggle = new ActionBarDrawerToggle(this, dLayout,mtoolar,  R.string.drawer_open, R.string.drawer_close)
    {
        /** Called when a drawer has settled in a completely closed state. */
        public void onDrawerClosed(View view) {
            super.onDrawerClosed(view);
        }
        /** Called when a drawer has settled in a completely open state. */
        public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
        }
    };
   // Set the drawer toggle as the DrawerListener
    dLayout.setDrawerListener(mDrawerToggle);
    mDrawerToggle.syncState();
}

private void setNavigationDrawer() {
    dLayout=(DrawerLayout) findViewById(R.id.drawer_layout);
    navView=(NavigationView) findViewById(R.id.navigation);
    navView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
        @Override
        public boolean onNavigationItemSelected(MenuItem menuItem) {
           int itemId = menuItem.getItemId();

            if (itemId == R.id.home_item) {
                         }
            else if (itemId == R.id.about_app) {
                             }
            return false;
        }
    });
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.menu_main, menu);
    return super.onCreateOptionsMenu(menu);
}
}
toolbar.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar       xmlns:android="http://schemas.android.com/apk/res/android"    android:id="@+id/tool_bar"
android:layout_width="wrap_content"
android:layout_height="?attr/actionBarSize"
android:background="@color/colorPrimary"
android:theme="@style/AppTheme"
android:elevation="8dp">

</android.support.v7.widget.Toolbar>
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.zenica.app.zenica" >
   <application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme"
    android:uiOptions="splitActionBarWhenNarrow">

    <activity
        android:name=".SplashScreenActivity"
        android:screenOrientation="portrait"
        android:theme="@style/AppTheme">
        <intent-filter >
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <activity
        android:name=".HomeActivity"
        android:theme="@style/AppTheme">
    </activity>

</application>
</manifest>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorPrimaryLight">#C5CAE9</color>
<color name="textColorPrimary">#212121</color>
<color name="textColorSecondary">#727272</color>
<color name="windowBackground">#FFFFFF</color>
<color name="navigationBarColor">#000000</color>
<color name="colorAccent">#FF5252</color>
<color name="icons">#FFFFFF</color>
<color name="listDivider">#68FF66</color>
</resources>

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar       xmlns:android="http://schemas.android.com/apk/res/android"    android:id="@+id/tool_bar"
android:layout_width="wrap_content"
android:layout_height="?attr/actionBarSize"
android:background="@color/colorPrimary"
android:theme="@style/AppTheme"
android:elevation="8dp">

</android.support.v7.widget.Toolbar>
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.zenica.app.zenica" >
   <application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme"
    android:uiOptions="splitActionBarWhenNarrow">

    <activity
        android:name=".SplashScreenActivity"
        android:screenOrientation="portrait"
        android:theme="@style/AppTheme">
        <intent-filter >
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <activity
        android:name=".HomeActivity"
        android:theme="@style/AppTheme">
    </activity>

</application>
</manifest>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorPrimaryLight">#C5CAE9</color>
<color name="textColorPrimary">#212121</color>
<color name="textColorSecondary">#727272</color>
<color name="windowBackground">#FFFFFF</color>
<color name="navigationBarColor">#000000</color>
<color name="colorAccent">#FF5252</color>
<color name="icons">#FFFFFF</color>
<color name="listDivider">#68FF66</color>
</resources>

colors.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar       xmlns:android="http://schemas.android.com/apk/res/android"    android:id="@+id/tool_bar"
android:layout_width="wrap_content"
android:layout_height="?attr/actionBarSize"
android:background="@color/colorPrimary"
android:theme="@style/AppTheme"
android:elevation="8dp">

</android.support.v7.widget.Toolbar>
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.zenica.app.zenica" >
   <application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme"
    android:uiOptions="splitActionBarWhenNarrow">

    <activity
        android:name=".SplashScreenActivity"
        android:screenOrientation="portrait"
        android:theme="@style/AppTheme">
        <intent-filter >
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <activity
        android:name=".HomeActivity"
        android:theme="@style/AppTheme">
    </activity>

</application>
</manifest>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorPrimaryLight">#C5CAE9</color>
<color name="textColorPrimary">#212121</color>
<color name="textColorSecondary">#727272</color>
<color name="windowBackground">#FFFFFF</color>
<color name="navigationBarColor">#000000</color>
<color name="colorAccent">#FF5252</color>
<color name="icons">#FFFFFF</color>
<color name="listDivider">#68FF66</color>
</resources>

#3F51B5
#303F9F
#C5CAE9
#212121
#727272
#FFFFFF
#000000
#FF5252
#FFFFFF
#68FF66
导航u drawer.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"
android:background="?android:attr/listDivider"
tools:context=".HomeActivity" >

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

<android.support.design.widget.NavigationView
android:id="@+id/navigation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="start"
app:itemTextColor="#333"
app:itemIconTint="#ddd"
app:menu="@menu/navigation_items"
    app:contentInsetEnd="0dp"
    app:contentInsetStart="0dp"/>

<include
    android:id="@+id/toolbar"
    layout="@layout/toolbar" />

</LinearLayout>

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


在抽屉中显示布局文件导航question@DhawalSodhaParmar-现在我添加了导航\u drawer.xml文件,比较您的代码