我想从我的工具栏中删除不需要的标题

i want to remove that unwanted Title from my toolbar

问题是我正在将来自另一个布局的那些文本视图膨胀到工具栏中我将提供他们的代码 below.I 已经尝试了所有可能的事情 do.It 没有甚至以编程方式进行

这是我展开布局并设置自定义视图的代码

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

试试这个

getSupportActionBar().setDisplayShowTitleEnabled(false);

在清单声明时

<activity
    android:name="com.example.nikhil_pc.fritz.MainActivity"
    android:label="@string/app_name"
    android:launchMode="singleTop"
    android:screenOrientation="portrait"
    android:theme="@style/AppTheme.NoActionBar">

label标签是工具栏标题。您可以从清单中删除它,也可以在 onCreate 方法调用 setTitle(null)

中删除它