【问题标题】:Not able to see App Name in Android application无法在 Android 应用程序中看到应用程序名称
【发布时间】:2020-04-14 14:07:12
【问题描述】:

我没有在操作栏上看到我的应用程序名称。

所以请帮我弄清楚它被隐藏的原因以及如何解决这个问题。

这是我的代码:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
   >

    <com.google.android.material.appbar.AppBarLayout
        android:id="@+id/appBarLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">


            android:id="@+id/my_Toolbar"
            layout="@layout/my_toolbar"

        <com.google.android.material.tabs.TabLayout
            android:id="@+id/tabLayout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"/>

    </com.google.android.material.appbar.AppBarLayout>

    <androidx.viewpager.widget.ViewPager
        android:id="@+id/viewPager"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/appBarLayout"/>

</RelativeLayout>

【问题讨论】:

    标签: android android-studio android-layout menu android-actionbar


    【解决方案1】:

    在你的manifest文件中在对应的activity处添加一个标签,例如:

     <activity
            android:name=".MainActivity"
            android:label="app_name"
    

    您还可以在活动中以编程方式设置标题:

      getSupportActionBar().setTitle("My app name");
    

    【讨论】:

      【解决方案2】:

      对于科特林: supportActionBar?.title = "我的应用名称"

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2015-07-21
        • 1970-01-01
        • 2020-10-07
        • 2014-02-12
        • 2017-04-12
        • 2016-01-29
        • 2017-05-10
        • 1970-01-01
        相关资源
        最近更新 更多