How to leave imageView behind the buttons?

Asked

Viewed 1,571 times

1

as the ramaral posted seven code:

In your Activity Layout you must declare an Imageview

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

<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, in the onClick of the button, 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 wonder if there’s any way she can hide behind the buttons .

  • Only use one FrameLayout, which guides the provision of Views as if it were a stack. Overlapping as the declaration.

  • Just use the bringToFront in ImageView. On devices prior to 4.4 it is necessary to execute a requestLayout followed by a invalidate afterward.

1 answer

7


To assemble a layout with overlap on the Z axis just use the FrameLayout.

The FrameLayout draws the View's stacking them according to the order in which they were declared.

Example:

Ordenação vertical

To bring a View to the top, only use the method: View.bringToFront, that will modify the order of View's in the parent list. For devices prior to Kitkat (4.4), just call requestLayout and then invalidate in own View.

References: http://android-developers.blogspot.com.br/2011/09/thinking-like-web-designer.html

Browser other questions tagged

You are not signed in. Login or sign up in order to post.