Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/229.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-core/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 更改其容器内的SeekBar位置_Android_Android Progressbar_Android Seekbar - Fatal编程技术网

Android 更改其容器内的SeekBar位置

Android 更改其容器内的SeekBar位置,android,android-progressbar,android-seekbar,Android,Android Progressbar,Android Seekbar,每当扩展类时,将在其容器的垂直中心绘制条。我需要将文本放置在栏上方,增加高度(我在视图上设置了任意高度)会导致栏下方出现大量空白。我已经在谷歌上搜索了很长一段时间了,但我发现大部分都是关于拇指的,我需要在它的容器底部画条 这就是我试图作为单个视图实现的目标(注意,该条在“不居中”视图中的位置): 我能找到的唯一“有用”代码是: Window window = ((Activity) getContext()).getWindow(); window.setGravity(Gravity.BOT

每当扩展类时,将在其容器的垂直中心绘制条。我需要将文本放置在栏上方,增加高度(我在视图上设置了任意高度)会导致栏下方出现大量空白。我已经在谷歌上搜索了很长一段时间了,但我发现大部分都是关于拇指的,我需要在它的容器底部画条

这就是我试图作为单个视图实现的目标(注意,该条在“不居中”视图中的位置):

我能找到的唯一“有用”代码是:

Window window = ((Activity) getContext()).getWindow();
window.setGravity(Gravity.BOTTOM);
WindowManager.LayoutParams wmlp = window.getAttributes();
wmlp.y = getHeight() / 4;
window.setAttributes(wmlp);
但它没有任何效果

我的自定义类,没有任何异常:

public class RateSeekbar extends AppCompatSeekBar {

    private Paint lettersPaint;
    private Paint numberPaint;

    // constructors and call to init()

    private void init() {
        lettersPaint = new Paint();
        numberPaint = new Paint();
        ... // style the two different paints
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);

        ... // get a couple of strings from resources and measure them 
        int middleHor = getWidth() / 2;
        canvas.drawText(text1, getPaddingLeft(), 40, lettersPaint);
        canvas.drawText(text2, getWidth() - text2Size - getPaddingRight(), 40, lettersPaint);
        canvas.drawText(String.valueOf(getProgress()), middleHor - (text3Size / 2), 50, numberPaint);
    }
}

有什么想法吗?

你能分享一下你正在努力实现的目标和你目前拥有的东西的截图吗,也可以发布你的xml@SuhaibRoomy没有XML,我只使用一个自定义视图。我试图实现的是在容器底部绘制条,在构造函数中添加paddingTop,这会导致我在顶部绘制的文本也移动。我只需要偏移栏的位置。请张贴您的自定义视图代码