为膨胀的视图活动设置标题

时间:2017-08-15 07:32:17

标签: android android-layout android-activity title layout-inflater

My activity screenshot having red highlight area where i want to set title

我在我的活动中夸大了一个视图。我想为它设置一个标题,清单中的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); 标记无法正常工作我已经尝试了几千次。 如何在屏幕截图的突出显示区域设置标题我的代码如下所示

Dim fs_infos() As FileInfo = dir_info.GetFiles("*.txt")
For Each fs_info As FileInfo In fs_infos
    listbox1.items.add(fs_info.FullName)
Next

1 个答案:

答案 0 :(得分:0)

如果您想在应用栏的右上角设置标题,可以在TextView中添加Toolbar

<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>

Toolbar布局顶部添加此Activityactivity_main.xml

相关问题