控制android布局中的问题

时间:2011-09-16 12:24:17

标签: android relativelayout layoutparams

我试图在relativelayout的中心显示新视图。 但新视图始终位于屏幕顶部。

LayoutInflater inflater = (LayoutInflater)this.getSystemService("layout_inflater");
dest = inflater.inflate(R.layout.searchlayout, ViewGroup)      
this.findViewById(R.layout.pdfview));
RelativeLayout.LayoutParams params = new     RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,  RelativeLayout.LayoutParams.WRAP_CONTENT);
params.addRule(RelativeLayout.CENTER_VERTICAL);
dest.setLayoutParams(params);
this.addContentView(dest, params);

0 个答案:

没有答案