I have created CustomView. The view is higher in size than the screen. So it is showing fully in the device s开发者_开发问答creen.
I want to determine position to determine how much it is outside the screen in left, right top and bottom. How to do that?
For what purpose you want to know how much of your view is outside of the screen? Can't you just use Scroller?
You can call getLocalVisibleRect on the view to get the "on screen" rectangle.
For example say in your onDraw
@Override
protected void onDraw(Canvas canvas) {
Rect r=new Rect();
getLocalVisibleRect(r);
// 0 to r.top is above the visible screen, etc
...
Once you have that rect it should be simple to calculate the values you want.
精彩评论