【问题标题】:How to set tint color for setCompoundDrawablesWithIntrinsicBounds?如何为 setCompoundDrawablesWithIntrinsicBounds 设置色调颜色?
【发布时间】:2017-03-29 07:26:20
【问题描述】:

我有一个选项卡布局,我在其中设置文本和矢量图像,如下所示:

    TextView tab2 = (TextView) LayoutInflater.from(this).inflate(R.layout.custom_tab, null);
    tab2.setText("OFFER");
    tab2.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.ic_offer, 0, 0);
    tabLayout.addTab(tabLayout.newTab().setCustomView(tab2));

如何更改可绘制矢量图像的色调颜色?

【问题讨论】:

    标签: android image android-vectordrawable tint


    【解决方案1】:

    试试这样:

    Drawable drawables[] = textView.getCompoundDrawables();
    drawables[0].setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_IN));
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-07-22
      • 2016-10-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-02-19
      • 1970-01-01
      相关资源
      最近更新 更多