Created
August 7, 2010 20:02
-
-
Save bryanjswift/513128 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.bryanjswift.android.view; | |
import android.content.Context; | |
import android.graphics.Rect; | |
import android.util.AttributeSet; | |
import android.util.Log; | |
import android.widget.EditText; | |
import android.widget.ScrollView; | |
/** | |
* Custom EditText to allow the ScrollView to handle displaying the proper rectangle by killing requests for | |
* different rectangles | |
* @author bryanjswift | |
*/ | |
public class ScrollWrappableEditText extends EditText { | |
private static final String LOGGING_TAG = ScrollWrappableEditText.class.getSimpleName(); | |
/** | |
* Default constructor | |
* @param context to which this View is being added | |
*/ | |
public ScrollWrappableEditText(Context context) { | |
super(context); | |
} | |
/** | |
* Default constructor | |
* @param context to which this View is being added | |
* @param attrs used when creating the View | |
*/ | |
public ScrollWrappableEditText(Context context, AttributeSet attrs) { | |
super(context, attrs); | |
} | |
/** | |
* Default constructor | |
* @param context to which this View is being added | |
* @param attrs used when creating the View | |
* @param defStyle id of style definition to add to attrs | |
*/ | |
public ScrollWrappableEditText(Context context, AttributeSet attrs, int defStyle) { | |
super(context, attrs, defStyle); | |
} | |
/** | |
* Don't request this view move if it is wrapped in a ScrollView | |
* @see android.view.View#requestRectangleOnScreen(android.graphics.Rect, boolean) | |
*/ | |
@Override | |
public boolean requestRectangleOnScreen(Rect rectangle, boolean immediate) { | |
// Always return true, the ScrollView around this will handle the proper rectangle being on screen | |
if (getParent() instanceof ScrollView) { | |
Log.d(LOGGING_TAG, "Wrapped in ScrollView tell call request is complete"); | |
return true; | |
} else { | |
Log.d(LOGGING_TAG, "Not wrapped by ScrollView, handle normally"); | |
return super.requestRectangleOnScreen(rectangle, immediate); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment