FrameLayout rv =(FrameLayout)findViewById(R.id.my_ph);
ImageView im1 = new ImageView(this);
im1.setBackgroundResource(R.drawable.lamp_on);
im1.layout(100, 100,120, 120);
rv.addView(im1);
<FrameLayout android:id="@+id/my_ph" xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/sketch" />
</FrameLayout>
FrameLayout android:id="@+id/my_ph"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/sketch" android:layout_alignParentTop="true"/>
<ImageView
android:id="@+id/image2"
android:layout_width="fill_parent"
android:layout_height="fill_paren"
android:layout_alignTop="@id/image"
android:layout_alignLeft="@id/image"
android:layout_alignRight="@id/image"
android:layout_alignBottomp="@id/image"
android:visibility="INVISIBLE"/>
</FrameLayout>
ImageView image2 =(ImageView)findViewById(R.id.image2);
image2.setVisibility(View.VISIBLE);
image2.setImageResource(R.drawable.my_image);
RelativeLayout rv = (RelativeLayout) findViewById(R.id.my_ph);
RelativeLayout.LayoutParams params;
ImageButton im1 = new ImageButton(this);
im1.setBackgroundResource(R.drawable.lamp);
im1.setId(i);
im1.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
TextView tx = (TextView) findViewById(R.id.textView1);
tx.setText("lamp #" + v.getId());
}
});
params = new RelativeLayout.LayoutParams(40, 40);
params.leftMargin = x;
params.topMargin = y;
rv.addView(im1, params);
<RelativeLayout android:id="@+id/my_ph"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="bottom">
<ImageView android:id="@+id/image" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_alignParentTop="true"
android:background="@drawable/map" />
<TextView android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceLarge" android:layout_below="@+id/image" android:layout_alignParentLeft="true"></TextView>
</RelativeLayout>
ImageView img=(ImageView)findViewById(R.id.image);
img.setBackgroundDrawable(getResource().getDrawable(R.drawable.lamp_on));
ImageView im1 = new ImageView(this);
im1.setBackgroundResource(R.drawable.lamp_on);
im1.layout(100, 100,120, 120);
rv.addView(im1);
<FrameLayout android:id="@+id/my_ph" xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/sketch" />
</FrameLayout>
FrameLayout android:id="@+id/my_ph"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/sketch" android:layout_alignParentTop="true"/>
<ImageView
android:id="@+id/image2"
android:layout_width="fill_parent"
android:layout_height="fill_paren"
android:layout_alignTop="@id/image"
android:layout_alignLeft="@id/image"
android:layout_alignRight="@id/image"
android:layout_alignBottomp="@id/image"
android:visibility="INVISIBLE"/>
</FrameLayout>
ImageView image2 =(ImageView)findViewById(R.id.image2);
image2.setVisibility(View.VISIBLE);
image2.setImageResource(R.drawable.my_image);
RelativeLayout rv = (RelativeLayout) findViewById(R.id.my_ph);
RelativeLayout.LayoutParams params;
ImageButton im1 = new ImageButton(this);
im1.setBackgroundResource(R.drawable.lamp);
im1.setId(i);
im1.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
TextView tx = (TextView) findViewById(R.id.textView1);
tx.setText("lamp #" + v.getId());
}
});
params = new RelativeLayout.LayoutParams(40, 40);
params.leftMargin = x;
params.topMargin = y;
rv.addView(im1, params);
<RelativeLayout android:id="@+id/my_ph"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="bottom">
<ImageView android:id="@+id/image" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_alignParentTop="true"
android:background="@drawable/map" />
<TextView android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceLarge" android:layout_below="@+id/image" android:layout_alignParentLeft="true"></TextView>
</RelativeLayout>
ImageView img=(ImageView)findViewById(R.id.image);
img.setBackgroundDrawable(getResource().getDrawable(R.drawable.lamp_on));
If the answers is incorrect or not given, you can answer the above question in the comment box. If the answers is incorrect or not given, you can answer the above question in the comment box.