我用.xml创建了我的用户界面,但是我想通过动态指定按钮的方向。 举例;Android中的动态按钮指示
<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<Button
android:id="@+id/backbutton"
android:text="TEST123"
android:layout_x="120px"
android:layout_y="120px"
android:layout_width="100px"
android:layout_height="100px" />
</AbsoluteLayout>
然后就是我的活动我班通过动态类似的改变的东西。
AbsoluteLayout al = new AbsoluteLayout(this);
Button t = new Button(this);
t.setHeight(300);
t.setWidth(300);
t.setText("TEST123");
// x y ???
setContentView(al);
我改变了高度和宽度..但我找不到改变x和y方向的方法。
你能举个例子记录我的代码吗? – Dapina 2011-05-09 20:31:07
顶部,左边,右边,底部是什么意思? – Dapina 2011-05-09 20:35:53
它们是填充参数。 – yogsma 2011-05-09 20:38:08