@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
int out_h = rl.getHeight();
ViewGroup.LayoutParams in_lp = tv.getLayoutParams();
in_lp.height = out_h*(100-progress)/100;
tv.setLayoutParams(in_lp);
tv.requestLayout();
Log.i("Ma","----out==="+out_h+"=====int====="+in_lp.height);
}以TextView tv为例:
利用seekbar动态控制控制tv的高度:out_h 父控件的高度
~必须要使用LayoutParams才可以动态加载。
本文介绍了一种使用SeekBar来动态调整TextView高度的方法。通过监听SeekBar的变化,并根据SeekBar的进度值来计算TextView的高度,实现了高度的动态调整。此方法适用于需要灵活调整UI组件高度的场景。
112

被折叠的 条评论
为什么被折叠?



