相关疑难解决方法(0)

如何更改操作栏上的文本

目前它只显示应用程序的名称,我希望它显示自定义的内容,并在我的应用程序中为每个屏幕显示不同的内容.

例如:我的主屏幕可以在操作栏中显示"page1",而应用切换到的另一个活动可以在该屏幕操作栏中显示"page2".

android android-actionbar

227
推荐指数
7
解决办法
40万
查看次数

ActionBar上没有应用程序图标

这里有很多关于向ActionBar添加图标的问题但没有解决我的问题.如果您知道此问题的副本,请随时发表评论或关闭此问题.

我将我的项目迁移到IntelliJ,我没有遇到过我以前的IDE(Eclipse)的问题.

问题:应用程序图标未显示在ActionBar中.

在此输入图像描述

我认为它应该默认添加,这就是为什么我不能通过它添加它

在此输入图像描述

这是它的XML

<menu 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"
    tools:context=".MainActivity" >

    <item android:id="@+id/action_settings"
        android:title="@string/action_settings"
        android:orderInCategory="100"
        app:showAsAction="always" />
</menu>
Run Code Online (Sandbox Code Playgroud)

谢谢!

android intellij-idea android-actionbar

33
推荐指数
3
解决办法
4万
查看次数

Android:如何更改操作栏标题?

这是我的styles.xml文件.

<resources>

    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <item name="colorPrimary">@color/colorPrimary4</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark4</item>
        <item name="colorAccent">@color/colorAccent2</item>
        <item name="android:fontFamily">fonts/HelveticaNeue-Light.ttf</item>
    </style>

    <style name="AppTheme.NoActionBar">
        <item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>
    </style>

    <style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />

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

    <style name="AppTheme.Widget" />

    <style name="AppTheme.Widget.TextView" parent="android:Widget.Holo.Light.TextView">
        <item name="android:fontFamily">fonts/HelveticaNeue-Light.ttf</item>
    </style>
</resources>
Run Code Online (Sandbox Code Playgroud)

这是包含工具栏的布局文件.

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
    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:fitsSystemWindows="true"
    tools:context=".HomeActivity">

    <android.support.design.widget.AppBarLayout android:layout_height="wrap_content"
        android:layout_width="match_parent" android:theme="@style/AppTheme.AppBarOverlay">

        <android.support.v7.widget.Toolbar android:id="@+id/toolbar"
            android:layout_width="match_parent" android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary" app:popupTheme="@style/AppTheme.PopupOverlay" />

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

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

</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)

所以,toolbar正在使用文件中AppTheme.PopOverlay定义的主题styles.xml.

目前工具栏上的标题被设置为默认的应用程序名称,我想更改标题,所以我已经尝试<item name="android:text">@string/customtitle</item>AppTheme.PopOverlay主题中包含该属性.它没用. …

java android

0
推荐指数
1
解决办法
8421
查看次数

标签 统计

android ×3

android-actionbar ×2

intellij-idea ×1

java ×1