How to leave imageView behind the buttons?

0

As ramaral posted seven code:

In the Layout of your Activity you must declare an ImageView

If you want it to be visible only after pressing a button you should include the android attribute: visibility="invisible"

<ImageView android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/imageView1" android:visibility="invisible" android:src="@drawable/nomeDaSuaImagem" /> In the Activity code, on the button's onClick, make it visible:

'Button button1; ImageView imageView1;

imageView1 = (ImageView) findViewById (R.id.imageView1); button1 = (Button) findViewById (R.id.button1); button1.setOnClickListener (new View.OnClickListener () {

@Override
public void onClick(View v) {

    imageView1.setVisibility(View.VISIBLE;
}

}); '

I'd like to know if there's any way to hide it behind the buttons.

    
asked by anonymous 27.01.2015 / 00:06

1 answer

6

To mount an overlapping layout on the Z axis, just use FrameLayout .

FrameLayout draws View's by stacking them in the order they were declared.

Example:

TobringaViewtothetop,justusethemethod: View.bringToFront , which will modify the order of View's in the list that the parent maintains. For devices prior to KitKat (4.4), just call requestLayout and then invalidate on own View .

References: link

    
27.01.2015 / 01:15