[英]Relative Layout width/height is not work programmatically?
I want to doing a relative layout programmatically and set android:layout_widht=60 android:layout_height=60.When i doing programmatically it is fill all screen? 我想以编程方式进行相对布局并设置android:layout_widht = 60 android:layout_height = 60.当我以编程方式执行时,它是否填满所有屏幕? How can i do that? 我怎样才能做到这一点?
my code:` 我的代码:`
RelativeLayout relativeLayout=new RelativeLayout(getContext());
RelativeLayout.LayoutParams rel_btn = new RelativeLayout.LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
rel_btn.height = 60;
rel_btn.width = 60;
relativeLayout.setLayoutParams(rel_btn);
this.setBackgroundResource(com.example.R.drawable.line);`
screen: 屏幕:
btn.getLayoutParams().width = width;
btn.getLayoutParams().height = height;
in fact, just use 事实上,只是使用
RelativeLayout.LayoutParams rel_btn = new RelativeLayout.LayoutParams(
60, 60);
that's OK. 没关系。 the problem maybe the background pic stretch the button 问题可能是背景图片拉伸按钮
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.