I was going to move the button position programmatically. The button is in relative layout. I researched and found that we can use .setY()or .setTop(). Looks like they should work the same.
But in my case, it .setTop()does not change the position at all, but .setY()only works. I am not sure what I misunderstood, but it is very strange for me.
Is there anyone 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>
source
share