How to Set background images
Xml file settings in the background image:
For any widget, button imageView or layout, add
[Java] android: background = "@ drawable/bg"
You can set the background image to bg.
Bg. bnp Paribas are stored in the drawable directory.
The drawable directory stores images shared by the size icons. Drawable-hdpi stores 240 WVGA800 simulators or board pictures. Drawable-mdpi stores the corresponding small image
[Java] <ImageView
Android: layout_width = "wrap_content"
Android: layout_height = "wrap_content"
Android: src = "@ drawable/pic"/>
In the same example, you can set the image as pic.png using src.pdf.
--------------------------------------------------------------------------------
Set or change the background image of a widget in java code:
[Java] Resources resources = getContext (). getResources ();
Drawable btnDrawable = resources. getDrawable (R. drawable. layout_bg );
Layout. setBackgroundDrawable (btnDrawable );
In the program, the background image of layout is dynamically modified and implemented using the setBackgroundDrawable () function. Set the background image to layout_bg.png.
Modify the background image of imageView1 to the background image of imageView2:
ImageView2.getDrawable () can obtain the background of Image 2. The value is of the Drawable type.
ImageView1.setImageDrawable (drawable); sets the background image of imageView1.
That is:
[Java] imageView1.setImageDrawable (imageView2.getDrawable ());
Translated by Zhang