2016-07-14 119 views

回答

1

有在Android清單label每一個活動標籤的屬性,可以使用工具欄中設置的名稱。

<activity 
      android:name=".MainActivity" 
      android:label="@string/app_name" <------ Activity Name 
      android:theme="@style/AppTheme.NoActionBar"> 

</activity> 

或者,你可以通過編程改變它通過:

getSupportActionBar().setTitle("ACTIVITY NAME"); 
4

試試這個,

getActionBar().setTitle("YOUR TITLE"); 
getSupportActionBar().setTitle("YOUR TITLE"); // provide compatibility to all the versions 

onCreate()您需要的活動。

通過XML

在你manifest.xml

<activity 
     android:name=".YOURActivity" 
     android:label="@string/YOUR_TITLE" 
/> 
0
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); 
    // Title and subtitle 
    toolbar.setTitle(R.string.about_toolbar_title); 
    toolbar.setSubtitleTextColor(Color.WHITE); 
    toolbar.setTitleTextColor(Color.WHITE); 
    toolbar.setBackgroundColor(getResources().getColor(
      R.color.themeToolbarColor)); 
    toolbar.setNavigationIcon(R.drawable.ic_action_back); 
1

可以在Manifest

<activity 
    android:name=".Contents.HomeActivty" 
    android:label="TITLE" /> 

OR

您提供標題所有活動可以etTitle以編程方式使用getSupportActionBar().setTitle("TITLE");

0

如果您想要具有不同的名稱,可以在strings.xml文件中更改它們。您可以更改現有變量

<string name="app_name">YourAppName</string> 

將'YourAppName'替換爲您想要的任何內容。

另外,您可以爲其他名稱添加新變量!

0

試試這個代碼:

<LinearLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:fitsSystemWindows="true" 
android:orientation="vertical"> 

<android.support.v7.widget.Toolbar    
    android:id="@+id/toolbar_actionbar" 
    android:background="@null" 
    android:layout_width="match_parent" 
    android:layout_height="?actionBarSize" 
    android:fitsSystemWindows="true" /> 
    .... 
</LinearLayout> 

在Java

Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_actionbar); 
     if(toolbar != null) { 
      setSupportActionBar(toolbar); 
      getSupportActionBar().setTitle("My custom toolbar!"); 

     } 
0

如果你想改變整個應用程序名稱,然後

<string name="app_name">YourAppName</string> 

但是,如果你想改變特定的活動標題Ë然後

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

</activity> 

或者,你可以改變它形成的.java編程方式:

getSupportActionBar().setTitle("ACTIVITY NAME"); 
相關問題