mardi 26 juillet 2016

How get Button coordinate?

I have a layout activity_main.xml:

    <Button
        android:id="@+id/button"
        android:layout_marginTop="50dp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal|top"
        android:text="@string/hover"/>

</FrameLayout>

How can i get Button's coordinate (x, y) on screen. for now I use:

button.getX()
button.getY()

but it return 0.0, How can i achieve this.
Thanks

Aucun commentaire:

Enregistrer un commentaire