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我得到了我的答案。努力工作 –