【发布时间】:2017-02-09 07:35:06
【问题描述】:
我打算以编程方式移动按钮的位置。按钮处于相对布局中。我研究并发现我们可以使用.setY() 或.setTop()。看起来它们应该工作相同。
但在我的情况下,.setTop() 根本不会改变位置,.setY() 只能工作。我不确定我误会了什么,但这对我来说很奇怪。
有没有人能正确解释setY() vs setTop()?
有什么区别?
这是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>
【问题讨论】:
-
其实setTop() 用1000或者10000也没用。
标签: java android android-layout android-studio