Displaying popup images on button click

早过忘川 提交于 2020-01-01 19:56:54

问题


Please refer the image given in the url http://docs.google.com/Doc?docid=0AQhgDtGvE2HgZGZ6cmtua185M2RneG5nYmNm&hl=en

My query is, How can I display the messages corresponding to the rounded buttons and the table row , when I click on the rounded button with question mark.

I know, I have to use listener for the ? button , but what should I do in listener exactly, such that when I click, it shows those alerts(images) and when I click again, it disappears.

For this UI, I have used Relative layout as was suggested here -- Aligning components at desired positions -- and it worked perfect for me.

So, do I need to change my base layout altogether for accomplishing this?


回答1:


You can use a FrameLayout as the base for your ui layout and then add an ImageView overlay. For example:

<FrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/MainFrame"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <!-- Put your normal layout stuff here -->

</FrameLayout>

Then in your code you can create the ImageView and add it to the MainFrame and it will overlay your UI, like this:

FrameLayout mainFrame = (FrameLayout)findViewById(R.id.MainFrame);
ImageView overlay = new ImageView(this);
overlay.setImageBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.overlay));
mainFrame.addView(overlay);

Then later you can call:

mainFrame.removeView(overlay);

to have it go away.



来源:https://stackoverflow.com/questions/2591859/displaying-popup-images-on-button-click

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!