简体   繁体   English

如何在android中弹出一些部分图像

[英]How to pop up some part image in android

i want to display the some part of image.like a comic book.i have one image like this. 我想要显示图像的某些部分。就像一本漫画书。我有一个像这样的图像。

这是实际的形象。

when i click on image some part display like this. 当我点击图像时,某些部分显示如下。

单击此部分图像时的第二个图像。

i want to display this type. 我想显示这种类型。 in this process i create some zip file witch contain the part of images of main image. 在这个过程中,我创建了一些包含主图像图像部分的zip文件。 i done to display every image sequence wise.but my problem is how to get the actual image's any part click and display this in like second screen? 我完成了显示每个图像序列。但我的问题是如何获得实际图像的任何部分点击并在第二个屏幕显示这个?

i can't get the image part id. 我无法获得图像部分ID。 so how to get this part of image id. 那么如何获得这部分图像ID。

so please help me. 所以请帮帮我。 i am stuck. 我卡住了。

If you have archive with parts of main image, so that means you made them manually, right? 如果您有主图像部分的存档,那么这意味着您手动制作它们,对吧? So, your comics book viewer will be applicable only for manually created content. 因此,您的漫画书阅读器仅适用于手动创建的内容。

It it's true, so there is no trouble to make some kind of config-file (for example xml-based or Properties file) which will contain size and position for each part. 这是真的,所以制作某种配置文件(例如基于xml或属性文件)没有任何问题,它将包含每个部分的大小和位置。

After that you can handle MotionEvent and detect id of part by coordinates from config. 之后,您可以处理MotionEvent并从config中检测部分的id。

You also can improve your application by cutting images on-fly. 您还可以通过即时剪切图像来改善您的应用程序。 It's not difficult. 这并不困难。

Example: 例:

Your image here ( page1.png ): 你的形象在这里( page1.png ):

--------------------------------
|                 |            |
|                 |            |
|                 |     2      |
|        1        |            |
|                 |            |
|                 |------------|
|                 |            |
|-----------------|            |
|                 |     4      |
|                 |            |
|                 |            |
|                 |------------|
|        3        |            |
|                 |            |
|                 |     5      |
|                 |            |
|                 |            |
--------------------------------

Your simple config ( page1.cfg ): 你的简单配置( page1.cfg ):

# Parts description
# id=x,y;w,h
1=0,0;18,9
2=19,0;13,7
3=0,10;18,11
4=19,8;13,7
5=19,15;13,6

Your zip: 你的邮编:

page1.png
page1-1.png
page1-2.png
page1-3.png
page1-4.png
page1-5.png
page1.cfg
...

you can do One Trick for this Problem. 你可以为这个问题做一个技巧。

Set Buttons(With Background as Transparent) inside layouts. 在布局内设置按钮(背景为透明)。

Set OnclickListener of buttons to Show your PopUps which you want inside your class activity. 设置按钮的OnclickListener以在课堂活动中显示您想要的PopUps。

you can also manage button Click Event by Visible/Invisible Feature to as per your requirement. 您还可以根据您的要求管理按钮按可见/不可见功能单击事件。

Edited 编辑

your xml will look like as below. 你的xml将如下所示。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/YOUR_IMAGE" >

    <Button
        android:id="@+id/btn_invisible"
        android:layout_width="85dp" 
        android:layout_height="30dp"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:layout_marginBottom="18dp"
        android:background="@android:color/transparent" />

</RelativeLayout>

and Inside your OnCreate() Method of your Activity Class. 和您的活动类的OnCreate()方法内部。

   @Override
protected void onResume() {
    // TODO Auto-generated method stub
    super.onResume();

    setContentView(R.layout.help_1);
    btn_invisible = (Button) findViewById(R.id.btn_invisible);
    btn_invisible.setOnClickListener(this);
}

@Override
public void onClick(View v) {
    // TODO Auto-generated method stub

    if (v == btn_invisible) {
        //Whatever Code you want to Use for Show Popups

    }

I am not sure but you can try it out once. 我不确定,但你可以尝试一次。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM