我的活动屏幕截图具有红色突出显示区域,我想在其中设置标题
我在活动中夸大了观点。我想为它设置一个标题,setTitle
和清单中的label
标签不起作用,我已经尝试了一千次。 如何在屏幕截图的突出显示区域中设置标题,我的代码如下
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);
如果要在应用栏的右上角设置标题,可以在Toolbar
中放置TextView
。
<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
布局中添加以下Toolbar
:activity_main.xml