In My Custom AbsoluteLayout, I override updateViewLayout as follows:
The parameter "view" here is an EditText.
@Override public void updateViewLayout(View view, ViewGroup.LayoutParams params) {
super.updateViewLayout(view, params);
params.height = ViewGroup.LayoutParams.WRAP_CONTENT;
params.width = ViewGroup.LayoutParams.WRAP_CONTENT;
view.setLayoutParams(params);
}
This causes the EditText to not wrap when it reaches the end of the custom layout. Here's a screenshot to show what's happening
EDIT : Just to clarify, it happens after dragging the EditText to anywhere on the view. Otherwise it works smoothly before dragging. In case it's cause is inside the onDrop Method. This is my OnDrop Method in my custom layout. I implemented by following this guide
public void onDrop(DragSource source, int x, int y, int xOffset, int yOffset,
DragView dragView, Object dragInfo)
{
final EditText v = (EditText) dragInfo;
int dragViewWdith = dragView.getWidth();
int dragViewHeight = dragView.getHeight();
int layoutWidth = this.getWidth();
int layoutHeight = this.getHeight();
int left = x - xOffset;
int top = y - yOffset;
L.e("layoutWidth : " + layoutWidth);
if (left < 0) {
left = 0;
}
if (left + dragViewWdith > layoutWidth) {
left = layoutWidth - dragViewWdith;
}
if (top < 0) {
top = 0;
}
if (top + dragViewHeight > layoutHeight) {
top = layoutHeight - dragViewHeight;
}
final MyAbsoluteLayout.LayoutParams params = new MyAbsoluteLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT, left, top);
v.post(new Runnable() {
@Override public void run() {
updateViewLayout(v, params);
}
});