首页上一页 1 下一页尾页 2 条记录 1/1页
本人使用代碼控制UI界面,兩個控件重叠
/**线性布局**/ LinearLayout layout = LinearLayout(); layout.setOrientation(LinearLayout.); layout.setGravity(Gravity.|Gravity.); Button btn = Button(); Button btn2 = Button(); btn.setText(); btn2.setText(); layout.addView(btn); layout.addView(btn2); setContentView(layout); /**相对布局**/ RelativeLayout layout2 = RelativeLayout(); Button btn1 = Button(); TextView tv1 = TextView(); btn1.setText(); tv1.setText(); layout2.addView(btn1); layout2.addView(tv1); RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams., RelativeLayout.LayoutParams.); lp.addRule(RelativeLayout.,RelativeLayout.); lp.addRule(RelativeLayout.,RelativeLayout.); tv1.setLayoutParams(lp); setContentView(layout2);
以上两个是代码中设置布局。你所说的重叠,就是相对布局叠放在了一起,希望以上的对你有帮助。