我的应用程序中有一个按钮,我想通过编程来更改它的位置。我已经在XML中创建了一个按钮,如下所示:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<Button android:text="@+id/Button01"
android:id="@+id/Button01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="50px"
android:layout_marginTop="10px"
>
</Button>
</LinearLayout>
假设我想将按钮的位置设置为距离左侧100像素(就像layout_marginLeft="100px"一样),我该如何以编程的方式实现?请帮助我解决这个问题。