作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我查看了其他链接并尝试了他们所说的,但似乎没有任何效果,但是当我添加一个搜索栏时,拇指最终会像这样被切断:
这是我的:
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);
}
我试着像其他人建议的那样将左右填充设置为拇指宽度的一半,但它看起来仍然像上图,我真的不知道还能做什么,任何帮助将不胜感激。谢谢!
最佳答案
您需要设置 minHeight 和 maxHeight 属性或您的 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/
我有一个具有可变数量子元素的固定大小的 div。我不知道 children 的大小。目标是缩小它们以适合父级。 例子: .parent { width: 100px; height: 100p
我是一名优秀的程序员,十分优秀!