1

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

I inflated a view in my activity.I want to set a title for it, setTitle and label tag in manifest is not working i have tried like thousand times. How to set title in highlighted area of screenshot my code for this is below

 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);
Arjun Gurung
  • 431
  • 3
  • 17
Uttam Meerwal
  • 324
  • 2
  • 12

1 Answers1

0

If you want to set a title at the right corner of your app bar, you can put a TextView in the 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>

Add this Toolbar in your Activity layout at the top: activity_main.xml

Bob
  • 13,447
  • 7
  • 35
  • 45