开发者

Dynamincally Expandable textView in Android?

开发者 https://www.devze.com 2023-04-11 04:23 出处:网络
I am looking to design a dynamically expandable texview, in that the user slides his finger from the edge of the textview, and the view expands, and whi开发者_如何转开发le resizing up itself, resizing

I am looking to design a dynamically expandable texview, in that the user slides his finger from the edge of the textview, and the view expands, and whi开发者_如何转开发le resizing up itself, resizing down the view above it.

I figure I could use an onTouchListener, with a switch/case to pick up touch translation, but the resizing part is where I am unsure about. Any ideas on what methods would work for this?


I would think you could put something like this inside the ACTION_MOVE portion of your touch listener. You can find start point and current point from taking the values out of the MotionEvent that get passed to you in onTouch(). If you want it to only re-size in one direction then you just have to worry about either x or y. If you want to resize in all directions then you'll have to get a distance for both X and Y and then call setHeight and setWidth with the values that you come up with.

int distanceFingerHasTraveled = fingerStartY - fingerCurrentY;
tv.setHeight(tv.getHeight() + distanceFingerHasTraveled);
0

精彩评论

暂无评论...
验证码 换一张
取 消