开发者

Rotate LinearLayout in Android

开发者 https://www.devze.com 2023-03-15 02:55 出处:网络
i want to use vertical ProgressBars. By default they are not available in Android, so i tri开发者_C百科ed to put them in a LinearLayout and rotate it by 90 degrees.

i want to use vertical ProgressBars. By default they are not available in Android, so i tri开发者_C百科ed to put them in a LinearLayout and rotate it by 90 degrees. The problem is, the LinearLayout doesn´t resize after the animation, so I tried to put some manual resize into the AnimationListener:

Listener:

public void onAnimationEnd(Animation animation) {
    changeBarLayoutBounds();
}

...

Activity:

private void changeBarLayoutBounds() {
    int newWidth = params.height; // the params I copied before animation
    params.height = params.width
    params.width = newWidth;

    barLayout.setLayoutParams(params);
    barLayout.requestLayout();
}

This method somehow doensn´t work at all, does anybody have an idea?

Thank you.


You could create a custom progress bar. HERE you can find an example. Just use clip and set gravity to top or bottom and use 9-pathes that could grow vertically. Hope this helps.

0

精彩评论

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