1

My activity screenshot having red highlight area where i want to set title設置充氣觀活動

一個頭銜,我膨脹的看法在我activity.I要設置一個標題爲它在清單setTitlelabel標籤不工作我已經試過像千倍。 如何設置在屏幕截圖的高亮區域標題我這個代碼如下

FrameLayout frameLayout = (FrameLayout) findViewById(R.id.frameHome); 
LayoutInflater layoutInflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE); 
View inflate = layoutInflater.inflate(R.layout.activity_main, null, true); 
frameLayout.addView(inflate); 
+0

[Android的工具欄標題中心和自定義字體(中可能的複製https://stackoverflow.com/questions/26533510/android-toolbar - 中心標題和自定義字體) –

+0

你可以按照此鏈接https://stackoverflow.com/questions/15560904/setting-custom-actionbar-title-from-fragment –

+0

thnx ** stanislav-bondar ** * * vishnu-kumar-singhvi **我得到了我的答案。正在努力。 –

回答

0

如果你想在你的應用程序欄右上角設置一個標題,你可以在ToolbarTextView

<android.support.v7.widget.Toolbar 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:id="@+id/app_bar" 
    android:layout_width="match_parent" 
    android:layout_height="?android:attr/actionBarSize" 
    > 
    <FrameLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     > 

     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="match_parent" 
      android:text="Your Title" 
      android:layout_gravity="end"/> 
    </FrameLayout> 
</android.support.v7.widget.Toolbar> 

Activity佈局在頂部添加此Toolbaractivity_main.xml

+0

它沒有添加我想要的。它只是在工具欄下面添加一個文本視圖@bob –

+0

您應該使用此工具欄作爲您的應用欄/操作欄。使用它作爲你的父主題:'Theme.AppCompat.Light.NoActionBar'。並將該工具欄設置爲操作欄。 – Bob

+0

thnx @bob我得到了我的答案。努力工作 –