我想以编程方式删除后台可绘制的@drawable/bg
。有没有办法做到这一点?
目前,我的布局中包含以下XML:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:id="@+id/widget29"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
android:background="@drawable/bg">
</RelativeLayout>
发布于 2011-07-26 15:25:30
尝尝这个
RelativeLayout relative = (RelativeLayout) findViewById(R.id.widget29);
relative.setBackgroundResource(0);
检查RelativeLayout documentation中的setBackground函数
发布于 2012-09-26 04:33:49
这帮我去掉了背景色,希望能对大家有所帮助。setBackgroundColor(Color.TRANSPARENT)
发布于 2013-07-20 20:05:13
此方法的最佳性能:
imageview.setBackgroundResource(R.drawable.location_light_green);
使用这个。
https://stackoverflow.com/questions/6826564
复制相似问题