I was going to move the button's position programmatically. Button is in relative layout. I'd researched and found that we can use .setY()
or .setTop()
. It looks like they should work the same.
But in my case, .setTop()
does not change the position at all and .setY()
works only. I'm not sure what I did misunderstand but it's very weird for me.
Is there anybody who can explain setY()
vs setTop()
correctly?
What is the difference?
This is layout.xml
:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"/>
</RelativeLayout>