Reputation: 331
I'm trying to control the width, height and position on screen of a view via seekbars. Until now I've manage to control the width and height but I have problems to set the position on screen. The way I'm using which works is via radio group to set gravity LEFT_TOP, LEFT_CENTER etc, with the use of LayoutParams:
mParams.gravity = Gravity.TOP | Gravity.LEFT;
and same for center,bottom, right etc. But I want to have more control and set the vertical position with the use of left(for left side of screen) and right(for right side) seekbars. I tried this way:
mParams.gravity = Gravity.LEFT | (screenHeight -seekBarProgress)
and the same for right side, but I get strange behaviour.
Upvotes: 0
Views: 156
Reputation: 331
I'm using layoutParams, and I think I found a way by using gravity and x,y:
mParams.gravity = Gravity.TOP | Gravity.LEFT;
mParams.y = 24;
Upvotes: 0
Reputation: 4673
mParams.gravity = Gravity.LEFT |
(screenHeight -seekBarProgress)
You can't apply arbitrary values to the Gravity property as you did above. You can only use predefined constant values which you can find here: Gravity.
Thus, you cannot move a view to an arbitrary position by changing GRAVITY.
Upvotes: 1