2016-12-25 14 views
0

私のアプリツールバーに特定のテキストを表示したいのですが、常にそのアプリの名前も表示します。アプリ名とTextViewのテキストのみを削除するにはどうすればよいですか?Androidアプリは常にツールバーにアプリ名を表示します

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

    <android.support.v7.widget.Toolbar 
     xmlns:app="http://schemas.android.com/apk/res-auto" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:minHeight="?attr/actionBarSize" 
     app:popupTheme="@style/AppTheme.PopupOverlay" 
     android:fitsSystemWindows="true" > 

     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:gravity="left" 
      android:textAppearance="?android:attr/textAppearanceLarge" 
      android:text="The title I want to show" 
      android:layout_alignParentTop="true" 
      android:layout_alignParentStart="true" /> 

    </android.support.v7.widget.Toolbar> 
</android.support.design.widget.AppBarLayout> 
+1

を指定します。android:label = "You Text"またはアクティビティクラスのgetSupportActionBar()。setTitle( "Your Text"); –

答えて

2

AndroidManifest.xmlファイルのアクティビティ宣言にラベルを追加します。

<activity 
     .... 
     android:label="Name of Your Screen" 
     .... 
    </activity> 
0

使用

<activity 
    android:label="blah-blah" /> 

マニフェストファイルに設定します。
またはtoolbar.setTitle("blah-blah");
ToolbarActionBarのように設定した場合は、actionBar.setTitle("blah-blah");に電話することができます。

1

あなたは、静的なテキストをしたい場合は、それを動的にしたい場合は、AndroidManifest.xml

... 
<activity 
    ... 
    android:label="{YOUR_DESIRED_TEXT}"> 
    ... 
</activity> 
... 

に各activityタグにandroid:label="{YOUR_DESIRED_TEXT}"を設定し、あなたがthis

getActionBar().setTitle("Hello world App"); 
// provide compatibility to all the versions 
getSupportActionBar().setTitle("Hello world App"); 

しかし、あなたが完全に取得する場合に使用しますタイトルバーを取り除いて、AppCompatActivityの代わりにActivityを拡張するか、アクションバーを非表示にすることができます。

ActionBar actionBar = getSupportActionBar(); 
actionBar.hide(); 
関連する問題