![](/img/trans.png)
[英]How to display toolbar icons inside an inflated view toolbar android java
[英]how add more icons in toolbar in MaterialViewPager android lib
您好,我嘗試使用MaterialViewPager進行編輯
我可以安裝它(示例版本)。 但我對動作欄和工具欄一無所知
我有2個相對問題:
1-此模板具有向右滑動,僅可向右滑動(不適用於此圖片的圖標)
我也想添加一些工具欄圖標。
但是我不知道如何添加圖標!
請參閱mainactivity.java代碼:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
setTitle("");
mViewPager = (MaterialViewPager) findViewById(R.id.materialViewPager);
toolbar = mViewPager.getToolbar();
mDrawer = (DrawerLayout) findViewById(R.id.drawer_layout);
if (toolbar != null) {
setSupportActionBar(toolbar);
final ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setDisplayShowHomeEnabled(true);
actionBar.setDisplayShowTitleEnabled(true);
actionBar.setDisplayUseLogoEnabled(false);
actionBar.setHomeButtonEnabled(true);
}
}
如果將if (toolbar != null)
更改為if(toolbar == null),則滑動圖標將隱藏,並且僅向右箭頭顯示如下:
我知道這不是魔術,但是我檢查了所有Java代碼和menu_main以及樣式文件夾中的所有文件。 我不知道這個數組如何出現在這里? 因為項目中沒有任何工具欄或操作欄。 以及如何添加更多圖標?
因此,這是我的問題:1-如何使活動圖標滑動? 2-“右箭頭”的來源在哪里,如何添加更多圖標?
以及如何將兩個圖標都保留在“ 1”和“ 2”中!
該圖標來自Google支持庫,並且根據Material design進行放置和管理。
更改或執行任何操作都違反了材料設計原則。
它應該是默認值。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.