从rangeseekbar中删除拇指文本

时间:2016-03-28 08:01:07

标签: android android-seekbar seekbar-thumb

我有一个范围搜索栏,如下图所示

enter image description here

我使用以下代码进行范围搜索栏集成:

https://github.com/yahoo/android-range-seek-bar

我的问题是,当我滚动它时,我想删除搜索栏的值 275 1064 ,并删除最小和最大标签,那么它可能吗?你们所有的建议都很明显。

6 个答案:

答案 0 :(得分:3)

使用compile:

'org.florescu.android.rangeseekbar:rangeseekbar-library:0.3.0'

并添加您的布局:

<org.florescu.android.rangeseekbar.RangeSeekBar xmlns:app="http://schemas.android.com/apk/res-auto" app:showLabels="false" app:valuesAboveThumbs="false" />

答案 1 :(得分:0)

所有这些文本都是使用onDraw() RangeSeekbar方法绘制的。您应该查看onDraw()中的代码,找到以下行:

canvas.drawText()

然后删除或修改它。

答案 2 :(得分:0)

答案 3 :(得分:0)

试试这个

将它放在你的Gradle中:

compile 'org.florescu.android.rangeseekbar:rangeseekbar-library:0.3.0'

这在你的Xml文件中

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
 xmlns:tools="http://schemas.android.com/tools"
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 android:paddingLeft="@dimen/activity_horizontal_margin"
 android:paddingRight="@dimen/activity_horizontal_margin"
 android:paddingTop="@dimen/activity_vertical_margin"
 android:paddingBottom="@dimen/activity_vertical_margin"
 tools:context=".MainActivity">

<LinearLayout
    android:id="@+id/seekbar_placeholder"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"/>
</RelativeLayout>

并在您的活动中添加此代码:

 RangeSeekBar<Integer> rangeSeekBar = new RangeSeekBar<Integer>(this);
 // Set the range
 rangeSeekBar.setRangeValues(15, 90);
 rangeSeekBar.setSelectedMinValue(20);
 rangeSeekBar.setSelectedMaxValue(88);

 // Add to layout
 LinearLayout layout = (LinearLayout) findViewById(R.id.seekbar_placeholder);
 layout.addView(rangeSeekBar);

答案 4 :(得分:0)

rsb是Android res-auto的命名空间。 在您的布局中的搜索栏中:

rsb:valuesAboveThumbs="false"

如果您将库用作文件夹:

修改远程搜索栏的strings.xml:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="demo_min_label"></string>
    <string name="demo_max_label"></string>
</resources>

答案 5 :(得分:0)

在RangeSeekBar java文件中,删除:

canvas.drawText(minLabel, 0, minMaxHeight, paint);
canvas.drawText(maxLabel, getWidth() - minMaxLabelSize, minMaxHeight, paint);

表示最小和最大标签

并删除

if (!selectedValuesAreDefault) {
        paint.setTextSize(mTextSize);
        paint.setColor(Color.WHITE);
        // give text a bit more space here so it doesn't get cut off
        int offset = PixelUtil.dpToPx(getContext(), TEXT_LATERAL_PADDING_IN_DP);

        String minText = String.valueOf(getSelectedMinValue());
        String maxText = String.valueOf(getSelectedMaxValue());
        float minTextWidth = paint.measureText(minText) + offset;
        float maxTextWidth = paint.measureText(maxText) + offset;

        if (!mSingleThumb) {
            canvas.drawText(minText,
                    normalizedToScreen(normalizedMinValue) - minTextWidth * 0.5f,
                    mDistanceToTop + mTextSize,
                    paint);

        canvas.drawText(maxText,
                normalizedToScreen(normalizedMaxValue) - maxTextWidth * 0.5f,
                mDistanceToTop + mTextSize,
                paint);

用于拇指文字

此外,由于您缩短了时间,因此您需要设置

public static final int HEIGHT_IN_DP = 18;
相关问题