你可以參考這個代碼,那麼你可以得到解決......只是採用按您的需求量的....
ActionBar actionBar = getActionBar();
actionBar.setDisplayShowTitleEnabled(false);
actionBar.setDisplayShowHomeEnabled(false);
actionBar.setDisplayShowCustomEnabled(true);
RelativeLayout relative = new RelativeLayout(getApplicationContext());
TextView tv1 = new TextView(this);
tv1.setText("Test1");
tv1.setTextColor(Color.GREEN);
tv1.setPadding(3,13,3, 12);
tv1.setId(1);
tv1.setOnClickListener(this);
TextView tv2 = new TextView(this);
tv2.setText("Test2");
tv2.setTextColor(Color.GREEN);
tv2.setPadding(3,13,3,12);
tv2.setId(2);
tv2.setOnClickListener(this);
TextView tv3 = new TextView(this);
tv3.setText("Test3");
tv3.setTextColor(Color.GREEN);
tv3.setPadding(3,13,3, 12);
tv3.setId(3);
tv3.setOnClickListener(this);
TextView tv4 = new TextView(this);
tv4.setText("Test3");
tv4.setTextColor(Color.GREEN);
tv4.setPadding(3,13,3, 12);
tv4.setId(4);
tv4.setOnClickListener(this);
LinearLayout ll = new LinearLayout(this);
ll.addView(tv1);
ll.addView(tv2);
ll.addView(tv3);
ll.addView(tv4);
relative.addView(ll);
actionBar.setCustomView(relative);
你說「它的工作」,但你還是不快樂。請考慮使用更多的單詞或甚至圖片來解釋您的問題。 – CommonsWare
我編輯了我的問題。 – SavasCinar
我可以在這裏問一個相關的問題嗎?我還嘗試通過將顯示設置爲false來刪除圖標和標題。我膨脹一個自定義視圖來替換圖標和標題。它可以工作,但是,在自定義視圖膨脹之前,我可以看到圖標和標題。對此有何想法? – user1923613