我該如何在EditText
的rigth corner中編程設置按鈕?我怎樣才能編程設置鑽頭od edittext中的按鈕?
FrameLayout fl = new FrameLayout(this);
lv.addView(fl);
searchTxt = new EditText(this);
fl.addView(searchTxt);
btnSearch = new Button(this);
我試試這個
btnSearch.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL);
fl.addView(btnSearch);
和
LinearLayout.LayoutParams param = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 0);
param.gravity = Gravity.RIGHT;
fl.addView(btnSearch, param);
但按鈕 - 在左上角..
你爲什麼不使用XML創建佈局? –