java - How to make View appear when button is clicked in android -


how possible? thanks! should put view (relativelayout) on-top view , make invisible , when user clicks button sets visible? or there easier way opens dialog(?) in middle of screen?

thanks!

you need layout put child view onto. safest linear layout since adding multiple child easy

fisrt create xml file in layouts.

for eg in layout add file named iv.xml

<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" >  <imageview     android:id="@+id/iv_iv"     android:layout_width="200dp"     android:layout_height="120dp"     android:padding="2dp"     android:scaletype="fitcenter"     android:src="@drawable/person_default_page" /> 

in layout want add create linear layout @+id/row_id in code when need add view

linearlayout ll = = (linearlayout) findviewbyid(r.id.row_id); ll.removeallviews(); view element = layoutinflater.from(this).inflate(r.layout.iv, ll, false); imageview image_iv = (imageview) element.findviewbyid(r.id.ri_iv); ll.addview(element); 

Comments