Android-获取资源Resources,设置Background
4289 点击·0 回帖
![]() | ![]() | |
![]() | Android中获取资源的代码如下: 1 //获取资源 2 Resources res = getBaseContext().getResources(); 3 Drawable draw=res.getDrawable(R.drawable.icon); 设置背景图如下: 1 //设置linearLayout的背景图,将Drawable对象放进去 2 linearLayout.setBackgroundDrawable(draw); | |
![]() | ![]() |