应用标题未明确定义但存在

时间:2019-10-17 22:13:46

标签: android android-layout android-fragments

我正在使用的应用具有一个预定义的标题,该标题在布局中不存在。

layout / activity_wallpaper.xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@id/screen_main"
    xmlns:android="http://schemas.android.com/apk/res/android">

    <ListView
        android:id="@android:id/list"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" />

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

</LinearLayout>

呈现为:

enter image description here

“应用标题”出现在以下位置:

xml / wallpaper.xml:

<?xml version="1.0" encoding="utf-8"?>
<wallpaper
  xmlns:android="http://schemas.android.com/apk/res/android"
    android:label="@string/app_name"
    android:settingsActivity="com.dayafternight.wallpaper.SettingsActivity"
    android:thumbnail="@drawable/app_icon">
</wallpaper>

该布局已加载到活动中:

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

    setContentView(R.layout.activity_wallpaper); 

,但未明确引用标题。标题在布局中插入的位置?

标题的标题显示在strings.xml中的一个条目:

<string name="app_name">App title</string>

和AndroidManifest.xml:

<application android:icon="@drawable/app_icon" android:label="@string/app_name" android:isGame="false" android:banner="@drawable/app_banner">

如何将应用程序名称作为活动布局的一部分丢弃?

1 个答案:

答案 0 :(得分:0)

我们可以通过几种方式做到这一点:

  1. 通过设置ActionBar不显示标题。

    getSupportActionBar().setDisplayShowTitleEnabled(false);
    

setContentView(..);通话之后。

  1. 按主题。

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

将此主题应用于AndroidManifest.xml文件中的活动:

    android:theme="@style/AppTheme.NoTitleActionBar">
  1. 如果我们使用一个标题,请在工具栏上设置一个空标题。

    <ToolBar
      ...
      app:title=""
    ../>