我在scrollview中设计了自定义EditText。如果我滚动EditText的内容,它工作正常。但是在编辑/输入文本时,如果我连续按“输入键”6或7次,而不是内容,则布局会滚动。
点击和触摸侦听器的代码:
this.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
v.setFocusable(true);
v.setFocusableInTouchMode(true);
v.getParent().getParent().requestDisallowInterceptTouchEvent(true);
}
});
this.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
ViewParent p = v.getParent().getParent();
p.requestDisallowInterceptTouchEvent(true);
return false;
}
});
适用于Android 4.2。 Android 4.4中存在问题。有人指导我。
修改 它做了一般的工作,比如设置背景颜色和样式。
代码:
if (this.textBoxObj == null) {
return;
}
Context context = activity.getApplicationContext();
// Setting frame
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
this.textBoxObj.frame.getFrameRect().getWidth(),
this.textBoxObj.frame.getFrameRect().getHeight());
params.leftMargin = this.textBoxObj.frame.getFrameRect().getX();
params.topMargin = this.textBoxObj.frame.getFrameRect().getY();
this.setLayoutParams(params);
this.setFocusable(false);
this.setText(this.textBoxObj.textContentInfo.text);
this.setHint(this.textBoxObj.placeHolderTextContentInfo.text);
if(isViewUpdate == false)
{
this.setBackgroundColor(DUIColor.getLifeColor(this.textBoxObj.objectGeneralProperties.bgColor,context));
try {
this.setTextColor(DUIColor.getLifeColor(this.textBoxObj.textContentInfo.textProperties.textColor,context));
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
this.setTextSize(this.textBoxObj.textContentInfo.textProperties.textFontSize);
try {
this.setTypeface(DUIFont.getTextFontType(this.textBoxObj.textContentInfo.textProperties.textFontType,context));
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
this.setGravity(new DUIAlignment().getTextAlignment(this.textBoxObj.textContentInfo.textProperties.alignmentId));
this.setSingleLine(new DUIAlignment().getTextToWrapOrNot((this.textBoxObj.textContentInfo.textProperties.lineBreakeModeId)));
this.addTextChangedListener(this);
this.clearFocus();
}
请有人指导我如何解决Android 4.4及更高版本的此问题。