Search code examples
androidtoolbarandroid-toolbar

i want to remove that unwanted Title from my toolbar


The thing is that i am inflating those textviews from another layout into a toolbar I'll provide their code below.I have tried all possible thing that i could do.It doesn't even go programmatically

This is the code where in i inflate that layout and set a custom view

    private DatabaseReference mRootRef;
private FirebaseAuth mAuth;

private String mChatUser;
private String mCurrentUserId;
private Toolbar mChatToolbar;
private TextView mTitleView;
private TextView mLastSeenView;


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_chat);

    mChatToolbar = (Toolbar) findViewById(R.id.chat_app_bar);
    setSupportActionBar(mChatToolbar);

    ActionBar actionBar = getSupportActionBar();

    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setDisplayShowCustomEnabled(true);

    mRootRef = FirebaseDatabase.getInstance().getReference();
    mAuth = FirebaseAuth.getInstance();
    mCurrentUserId = mAuth.getCurrentUser().getUid();

    mChatUser = getIntent().getStringExtra("user_id");
    String userName = getIntent().getStringExtra("user_name");

    LayoutInflater inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View action_bar_view = inflater.inflate(R.layout.chat_custom_bar, null);

    actionBar.setCustomView(action_bar_view);

    // ---- Custom Action bar Items ----

    mTitleView = (TextView) findViewById(R.id.custom_bar_title);
    mLastSeenView = (TextView) findViewById(R.id.custom_bar_seen);

Solution

  • Try this

    getSupportActionBar().setDisplayShowTitleEnabled(false);