I have a custom view with id R.id.dragableview inside a RelativeLayout, which moves up and down by drag and drop. My problem is, in the layout there is another view which depends on the dragable one:
<View android:id="@+id/dependent_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/dragableview"
/>
My problem is, when the dragable view moves, the other stays where it originally was. I want it to be below the other view always! how can I achieve that? Which method should I call from inside my custom view, so the other view can update its position? thanks
I think you've got two options:
Use a RelativeLayout and position your 2nd view at some position relative to your draggable view.
If option #1 doesn't work, you can also try translating your 2nd view by the same distance the 1st view gets dragged, using setTranslationX (float translationX)
and setTranslationY (float translationY)
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.