【发布时间】:2011-04-06 16:24:08
【问题描述】:
在下面的 sn-p 中,我怎样才能让 mClickable 与 mTextArea 的高度相同?
public class EditSpinner extends LinearLayout {
EditText mTextArea;
ImageButton mClickable;
public EditSpinner(Context context, String[] options) {
super(context);
setOrientation(HORIZONTAL);
setGravity(Gravity.CENTER_VERTICAL);
setBackgroundResource(android.R.drawable.edit_text);
setAddStatesFromChildren(true);
setPadding(0, 0, 0, 0);
mTextArea = new EditText(context);
mTextArea.setSingleLine(true);
mTextArea.setBackgroundResource(0);
addView(mTextArea, new LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 1.0f));
mClickable = new ImageButton(context);
mClickable.setBackgroundResource(0);
mClickable.setImageDrawable(
context.getResources().getDrawable(
android.R.drawable.btn_default_small));
//Scale to mTextArea.getHeight()... except getHeight doesn't work
addView(mClickable,
new LayoutParams(WRAP_CONTENT, WRAP_CONTENT));
}
}
【问题讨论】:
标签: android view android-layout android-edittext imagebutton