Android 在edittext中动态创建环绕效果
嗨 我正在尝试动态创建多行EditTextAndroid 在edittext中动态创建环绕效果,android,android-layout,Android,Android Layout,嗨 我正在尝试动态创建多行EditText RelativeLayout rel = (RelativeLayout) findViewById(R.id.layout_info); EditText tt = new EditText(getContext()); tt.setId(100); RelativeLayout.LayoutParams rp = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams
RelativeLayout rel = (RelativeLayout) findViewById(R.id.layout_info);
EditText tt = new EditText(getContext());
tt.setId(100);
RelativeLayout.LayoutParams rp = new RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.WRAP_CONTENT,
RelativeLayout.LayoutParams.FILL_PARENT);
rp.addRule(RelativeLayout.BELOW, R.id.lbl_infotitle);
rp.width = 0;
tt.setTextColor(Color.BLACK);
tt.setBackgroundColor(android.R.color.transparent);
tt.setMaxLines(5);
tt.setSingleLine(false);
tt.setGravity(Gravity.LEFT);
tt.setInputType(InputType.TYPE_TEXT_FLAG_MULTI_LINE);
tt.setText("This section helps to maintain the"
+ "Personal Profile of subscriber."
+ "Screen contains the link" + " to sub sections such as,");
tt.setLayoutParams(rp);
rel.addView(tt, new RelativeLayout.LayoutParams(
LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
但是我的编辑文本总是单线的。(无法获得包裹效果)如果有人能提供解决方案,那就太好了。它可能是多余的,但我引用了所有的解决方案,没有任何东西是动态工作的。请帮助我实现这一点。添加到您的编辑文本textChangeListener,并在重写的方法中执行所需的操作 比如说
edit.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
}
});
请有人编辑我的源代码。部分没有正确对齐。如何在这里设置包装效果。给我一些建议