简体   繁体   English

Android:如何在操作栏选项卡中更改图标大小?

[英]Android: How can I change icons size in Action Bar Tabs?

I created an Action Bar Tabs activity for my project. 我为我的项目创建了一个Action Bar Tabs活动。 I used 3 tabs and I added some icons. 我使用了3个标签,并添加了一些图标。 But the icons are shown in a small size, even if I downloaded them in 48dp. 但即使我以48dp下载它们,图标也会以小尺寸显示。

在此输入图像描述

My code is: 我的代码是:

<android.support.design.widget.TabLayout
        android:id="@+id/tabs"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

final private int[] tabIcons = {
        R.drawable.ic_photo_library,
        R.drawable.ic_chat,
        R.drawable.ic_people
};

private void setupTabsIcons() {

    tabLayout.getTabAt(0).setIcon(tabIcons[0]);
    tabLayout.getTabAt(1).setIcon(tabIcons[1]);
    tabLayout.getTabAt(2).setIcon(tabIcons[2]);

}

How could I change the size of the icons? 我怎么能改变图标的​​大小? I also have a FloatingActionButton with the same problem. 我也有一个具有相同问题的FloatingActionButton。 The icon inside it is small. 里面的图标很小。

Just add Tab you self. 只需添加Tab你自己。

TabLayout layout = new TabLayout(TestActvt.this);
View view = getLayoutInflater().inflate(R.layout.custom,null);
view.findViewById(R.id.img).setImageResource(R.drawable.img);
TabLayout.Tab tab = layout.newTab().setCustomView(view);
layout.addTab(tab);

FloatingActionButton only has 2 size : mini or normal and Iamge in them has fixed size. FloatingActionButton只有2个大小:mini或normal,其中Iamge有固定大小。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM