问题描述
- android 在代码中如何设置 根视图的宽高?
-
android 在代码中如何设置 根视图的宽高?如何设置视图container的宽高?
public void popEdit(EditText _edit)
{ //edit=_edit;
LinearLayout container=new LinearLayout(cont);
container.setOrientation(LinearLayout.HORIZONTAL); LinearLayout.LayoutParams lp1 =new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT-80, LinearLayout.LayoutParams.WRAP_CONTENT); lp1.weight=1; EditText content=new EditText(cont); content.setHint("写点什么吧..."); //content.setLayoutParams(lp1); container.addView(content, lp1); Button button=new Button(cont); button.setBackgroundDrawable(cont.getResources().getDrawable(R.drawable.bton4)); container.addView(button); pop = new PopupWindow(container, edit.getWidth(), LayoutParams.WRAP_CONTENT, true); pop.setTouchable(true); pop.setBackgroundDrawable(new BitmapDrawable()); // pop.setFocusable(true); pop.showAsDropDown(edit, 0, 0);//位于et下面 }
时间: 2024-10-15 13:55:30