TextView代码设置drawable
程序员文章站
2024-02-10 23:44:28
...
LayerDrawable drawable = (LayerDrawable) getResources().getDrawable(R.drawable.shape_lock_battery);
drawable.setLayerInset(1, 6, (int) batteryPix, 6, 6);
drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
mBinding.tvBattery.setCompoundDrawablePadding(20);
mBinding.tvBattery.setCompoundDrawables(drawable, null, null, null);
上一篇: Kotlin(6)简单Android控件