Zala Janaksinh
Zala Janaksinh

Reputation: 2927

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.

this is actual image.

when i click on image some part display like this.

Second image when click this part of image.

i want to display this type. in this process i create some zip file witch contain the part of images of main image. 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. so how to get this part of image id.

so please help me. i am stuck.

Upvotes: 10

Views: 849

Answers (2)

Oleksii K.
Oleksii K.

Reputation: 5429

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.

After that you can handle MotionEvent and detect id of part by coordinates from config.

You also can improve your application by cutting images on-fly. It's not difficult.

Example:

Your image here (page1.png):

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

Your simple config (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
...

Upvotes: 1

Bhavesh Patadiya
Bhavesh Patadiya

Reputation: 25830

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.

you can also manage button Click Event by Visible/Invisible Feature to as per your requirement.

Edited

your xml will look like as below.

<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.

   @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.

Upvotes: 0

Related Questions