如何在MaterialViewPager android lib中的工具栏中添加更多图标

时间:2015-07-03 09:28:22

标签: java android android-layout

在那里,我尝试使用MaterialViewPager

我可以安装它(示例版本)。但我对动作栏和工具栏

无能为力

我有两个相对的问题:

1-此模板有一个右侧滑动,只能在触摸右侧时使用(不能使用此图片的图标)

enter image description here

我还想添加一些工具栏图标。

但我不知道如何添加图标!

请参阅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),则滑动图标将隐藏,只显示右箭头,如下图所示:

enter image description here

我知道这不是魔术,但我检查了所有java代码和menu_main以及样式文件夹中的所有文件。我不知道这个阵列是怎么产生的?因为项目中没有任何工具栏或操作栏。以及如何添加更多图标?

所以这是我的问题: 1-如何激活图标滑动? 2-其中是右箭头的来源'以及如何添加更多图标?

enter image description here

如何将两个图标保留在' 1'和' 2' !

1 个答案:

答案 0 :(得分:0)

该图标来自Google支持库,根据材料设计进行放置和管理。

更改或执行任何操作违反了材料设计原则。

应该是默认的。

相关问题