gpt4 book ai didi

android - 默认 Seekbar 缩略图被截断

转载 作者:行者123 更新时间:2023-11-30 02:41:28 27 4
gpt4 key购买 nike

我查看了其他链接并尝试了他们所说的,但似乎没有任何效果,但是当我添加一个搜索栏时,拇指最终会像这样被切断:

enter image description here

这是我的:

public void addSeekBar(int topMargin, int leftMargin, int width, int height, final int myWidth) {
View st = new SeekBar(getBaseContext());
SeekBar slider = new SeekBar(st.getContext());

slider.setMax(9);
slider.setProgress(5);

slider.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {

public void onStopTrackingTouch(SeekBar seekBar) {

}

public void onStartTrackingTouch(SeekBar seekBar) {

}

@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {

drawStars((float) ((progress + 1) / 2.0), myWidth);

}
});
LayoutParams paramsText = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
paramsText.leftMargin = leftMargin;
paramsText.topMargin = topMargin;
paramsText.width = width;
paramsText.height = height;

//Other threads said to set the left and right margin to half the width
//of the thumb and set the thumb offset to 8, I did this here but it didn't
//seem to work
slider.setPadding(16, 0, 16, 0);
slider.setThumbOffset(8);

container.addView(slider, paramsText);
}

我试着像其他人建议的那样将左右填充设置为拇指宽度的一半,但它看起来仍然像上图,我真的不知道还能做什么,任何帮助将不胜感激。谢谢!

最佳答案

您需要设置 minHeightma​​xHeight 属性或您的 Seekbar,因为 Android 在放置拇指时会将它们考虑在内。

以下是有关该问题的更多信息:http://qtcstation.com/2011/05/android-how-to-fix-seekbar-bar-thumb-centering-issues/

关于android - 默认 Seekbar 缩略图被截断,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25694648/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com