0

This is my page layout.

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <LinearLayout
        android:id="@+id/fullMeetingView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="top"
        android:layout_weight=".1"
        android:background="@color/colorPaleGrey2"
        android:orientation="vertical">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:layout_marginTop="20dp">

            <TextView
                android:id="@+id/meeting_text"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:fontFamily="sans-serif-medium"
                android:gravity="center_horizontal"
                android:text="Entrepreneur Meet Up"
                android:textColor="@color/blackDark"

                android:textSize="20.1sp"
                android:textStyle="normal" />

            <TextView
                android:id="@+id/time"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@id/meeting_text"
                android:layout_centerInParent="true"
                android:layout_marginTop="10dip"
                android:fontFamily="sans-serif-medium"
                android:gravity="center_horizontal"
                android:lineSpacingExtra="6sp"
                android:text="(11:30AM - 4:00PM)"
                android:textColor="@color/bluey_grey_three"
                android:textSize="14sp"
                android:textStyle="normal" />

        </RelativeLayout>

        <RelativeLayout
            android:id="@+id/rlmainLayout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <com.kdcos.contsync.utilities.dragview.DragLayer
                android:id="@+id/framelayout"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="vertical">


            </com.kdcos.contsync.utilities.dragview.DragLayer>
            <RelativeLayout
                android:id="@+id/rl_dropView"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                android:background="@drawable/round_bg"
                android:padding="30dp">

                <ImageView
                    android:id="@+id/imageView"
                    android:layout_width="30dp"
                    android:layout_height="30dp"
                    android:layout_alignParentTop="true"
                    android:layout_centerHorizontal="true"
                    android:background="@drawable/ic_drop_cards" />

                <TextView
                    android:id="@+id/textView2"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_below="@+id/imageView"
                    android:layout_centerInParent="true"
                    android:layout_gravity="center_horizontal|center"
                    android:fontFamily="sans-serif"
                    android:gravity="center_horizontal"
                    android:lineSpacingExtra="10sp"
                    android:text="Drop Cards Here"
                    android:textColor="@color/blackDark"
                    android:textSize="10sp"
                    android:textStyle="normal" />
            </RelativeLayout>

            <RelativeLayout
                android:id="@+id/delete_zone_view"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true"
                android:gravity="bottom"
                android:orientation="horizontal"
                android:visibility="visible">

                <ImageView
                    android:id="@+id/deleteButton"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_centerInParent="true"                        android:padding="@dimen/margin_20dp"
                    android:background="@drawable/ic_delete" />
            </RelativeLayout>


        </RelativeLayout>



    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="bottom"
        android:layout_weight=".2">

        <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:app="http://schemas.android.com/apk/res-auto"
            xmlns:tools="http://schemas.android.com/tools"
            android:id="@+id/drawer_layout"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fitsSystemWindows="true"
            tools:openDrawer="start">

            <android.support.design.widget.CoordinatorLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:fitsSystemWindows="true"
                tools:context="com.guna.navigationviewonbothssides.MainActivity">

                <android.support.design.widget.AppBarLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:background="@android:color/transparent"
                    app:elevation="0dp">


                    <RelativeLayout
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content">


                        <android.support.design.widget.TabLayout
                            android:id="@+id/tabLayout"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_toLeftOf="@+id/menuRight"
                            android:background="@color/colorWhite"
                            android:minHeight="?attr/actionBarSize"
                            app:tabGravity="fill"
                            app:tabIndicatorColor="@color/colorTurquoiseBlue"
                            app:tabIndicatorHeight="3dp" />

                        <RelativeLayout
                            android:id="@+id/menuRight"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_alignParentRight="true"
                            android:background="@color/blackDark"
                            android:padding="10dp"
                            android:tint="@color/colorPrimary">

                            <ImageButton
                                android:layout_width="16dp"
                                android:layout_height="16dp"
                                app:srcCompat="@drawable/ic_menu_white_24dp"

                                />

                        </RelativeLayout>


                    </RelativeLayout>

                </android.support.design.widget.AppBarLayout>

                <android.support.v4.view.ViewPager
                    android:id="@+id/viewpager_meeting_landscape"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_alignParentStart="true"
                    android:layout_alignParentTop="true"
                    android:layout_marginTop="50dp"
                    android:background="@color/colorWhite" />

            </android.support.design.widget.CoordinatorLayout>


            <android.support.design.widget.NavigationView
                android:id="@+id/nav_view"
                android:layout_width="200dp"
                android:layout_height="match_parent"
                android:layout_gravity="end"

                android:fitsSystemWindows="true">

                <android.support.v7.widget.RecyclerView
                    android:id="@+id/recyclerview_drawer_list"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:paddingTop="10dp"
                    android:visibility="visible"
                    android:scrollbars="vertical" />


                <TextView
                    android:id="@+id/empty_view"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:paddingTop="10dp"
                    android:scrollbars="vertical"
                    android:gravity="center"
                    android:text="@string/no_meeting_fount"
                    android:visibility="gone" />
            </android.support.design.widget.NavigationView>
        </android.support.v4.widget.DrawerLayout>
    </LinearLayout>
</LinearLayout>

enter image description here

i want to get eject position coordinates so that i can perform some action when i drop listview item

i tried using getLocationInWindow() x and y coordinate but i always get x axis-0 while it not 0 position i have to get eject position or area of delete button so that i can touch list view item view to delete position please suggest me how to find delete image view coordinate or position .

Ahmed Rajab
  • 603
  • 3
  • 10
  • 28
Manoj Kumar
  • 97
  • 1
  • 1
  • 10

1 Answers1

0

I think the reason is that the view is not drawn on the screen yet when you try to get its coordinates which is why it always return 0 for its x or y coordiante

see the following link for a similar problem and get the solution from it see the following link Getting 0 Value for both X and Y Coordinate of view(Imagebutton) in android

Ahmed Rajab
  • 603
  • 3
  • 10
  • 28
  • I have applied same code i dont know why i am getting still zero x aixs. but y axis i am getting value – Manoj Kumar Jan 28 '18 at 09:55
  • may be there is something weird with the image....it may be wide enough to reach the left side of the screen so its x coordinator is 0....it is uncommon that the y coordinate is correct while the x is wrong @ManojKumar – Ahmed Rajab Jan 28 '18 at 11:15
  • actually i took Relatvie layout so i was getting 0 now i have taken image button so not its working but i need one help how to apply condition on view is dragged in that points area can you pleas suggest me how to apply condition like i have imageview whose cordinate (510,960) i want to get call back when other view comes in this area after dragged @Ahmed Rajab – Manoj Kumar Jan 29 '18 at 04:44
  • i think the following link may be helpful.....please accept my answer if it was helpful – Ahmed Rajab Jan 29 '18 at 05:19
  • which link @Ahmed Rajab – Manoj Kumar Jan 29 '18 at 05:30
  • I am sorry i forgot to paste it ...... https://developer.android.com/reference/android/view/DragEvent.html#getX @ManojKumar – Ahmed Rajab Jan 29 '18 at 17:41
  • i understand but i need condition means how i will find one view is dragged to another view position i need that condition imageview cordinate is 560,920 – Manoj Kumar Jan 29 '18 at 17:48
  • try this one hope it helps... https://stackoverflow.com/questions/48059416/check-if-dragged-view-is-within-the-bounds-of-another-view – Ahmed Rajab Jan 29 '18 at 19:37
  • i tries using this but there is some problem in some of point i am getting call back can even i tocuh view with that image view cordinate – Manoj Kumar Jan 30 '18 at 06:40
  • do you have cases of actionDown and actionMove and actionUP? @ManojKumar – Ahmed Rajab Jan 30 '18 at 13:09