Android Studio,我用java编写布局,这些代码应放在Activity文件的什么位置? 10
代码如下:RelativeLayoutrelativeLayout=newRelativeLayout(this);RelativeLayout.LayoutParams...
代码如下:
RelativeLayout relativeLayout=new RelativeLayout(this);
RelativeLayout.LayoutParams params=new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
params.addRule(RelativeLayout.CENTER_IN_PARENT);
TextView textView=new TextView(this);
textView.setText("移动应用");
textView.setTextColor(Color.RED);
textView.setTextSize(18);
relativeLayout.addView(textView,params);
setContentView(relativeLayout); 展开
RelativeLayout relativeLayout=new RelativeLayout(this);
RelativeLayout.LayoutParams params=new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
params.addRule(RelativeLayout.CENTER_IN_PARENT);
TextView textView=new TextView(this);
textView.setText("移动应用");
textView.setTextColor(Color.RED);
textView.setTextSize(18);
relativeLayout.addView(textView,params);
setContentView(relativeLayout); 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询