mRouteOnDraw = getResources().getDrawable(
R.drawable.main_map_icon_route_pressed);
mRouteTabBtn.setCompoundDrawables(null, mRouteOnDraw, null, null);
单纯这样是不会显示出来的,要在set前加上下面这句话。
mRouteOnDraw.setBounds(0, 0, 36,36);
设置Drawable显示
本文介绍如何在Android中正确设置Drawable资源使其可见。通过设置Drawable的边界并使用setCompoundDrawables方法,可以实现在按钮或其他视图上的图标显示。
mRouteOnDraw = getResources().getDrawable(
R.drawable.main_map_icon_route_pressed);
mRouteTabBtn.setCompoundDrawables(null, mRouteOnDraw, null, null);
单纯这样是不会显示出来的,要在set前加上下面这句话。
mRouteOnDraw.setBounds(0, 0, 36,36);
941

被折叠的 条评论
为什么被折叠?