public class FirstTest extends Activity {
public FirstTest() {
// TODO Auto-generated constructor stub
}
RelativeLayout currentLayout;
static int[] Deck = {
R.drawable.img1,
R.drawable.img2,
R.drawable.img3,
R.drawable.img4
};
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
currentLayout = new RelativeLayout(this);
for (int i = 0; i < Deck.length; i++) {
ImageButton img = new ImageButton(this);
img.setPadding(0, 0, 0, 0);
img.setImageResource(Deck[i]);
img.setAdjustViewBounds(true);
img.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
// BUT HOW MOVE THIS BUTTON????
}
});
currentLayout.addView(img);
}
setContentView(currentLayout);
}
}
也许这对其他人来说是微不足道的,但我刚刚找到了 width 和 height 属性修饰符。在尝试了很多例子后,我放弃了。
我怎样才能搬东西?为什么我找不到 xy 属性?