I found allot about changing the background color of an activity but not how to change the backgroundcolor of an imageview, like this as example:
<ImageView
android:id="@+id/imageView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:src="@drawable/ic_person_200x200"
android:layout_margin="10dp"
android:layout_span="3"
android:background="#52D017"
android:padding="1dp" />
Anyone?
In your java code, after creating the ImageView object you can try calling the setBackgroundColor() method which is inherited from View. Check out the docs for more info on this http://developer.android.com/reference/android/view/View.html#setBackgroundColor(int)
If adding android:background
attribute to the <ImageView>
doesn't work then you should apply it programmatically.
Remove android:background="#52D017"
from the <ImageView>
and add the following to your activity file
ImageView backgroundImg = (ImageView) findViewById(R.id.imageView2);
backgroundImg.setBackgroundColor(Color.rgb(100, 100, 50));
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.