代码改变世界

用代码动态设置ImageView的align布局

2011-09-15 20:31  清炒白菜  阅读(935)  评论(0)    收藏  举报
LinearLayout rootLayout = (LinearLayout)findViewById(R.id.root_layout);

LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
    LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
params.gravity = Gravity.RIGHT;

ImageView btnSend = new ImageView (this); 
btnSend.setLayoutParams(params);
rootLayout.addView(btnSend);

  

http://stackoverflow.com/questions/4616445/align-imageview-in-linearlayout-by-code