Android画布未显示在rtl

时间:2019-05-01 10:53:35

标签: android canvas android-recyclerview item-decoration

我正在使用以下代码在RecyclerView上绘制圆形和垂直线:

    @Override
    public void onDrawOver(Canvas c, RecyclerView parent, RecyclerView.State state) {
        int itemCount = parent.getAdapter().getItemCount();
        final int left = (int) (parent.getPaddingLeft() + (10 * DP));

        for (int i = 0; i <= itemCount; i++) {
            final View child = parent.getChildAt(i);
            if (child == null) { 
                continue;
            }

            final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
            final int top = child.getTop() + params.topMargin;
            final int bottom = child.getBottom();

            if (i != itemCount-1){
                drawVerticalLine(c,left,top+circleRadius*2+circleStroke,left,bottom-circleStroke);
            }

            drawCircle(c, left + child.getPaddingLeft(), top + circleRadius , circleRadius);


        }
        super.onDrawOver(c, parent, state);

应该是这样的:

o item1
|
|
o item2
|
|
o item3 ..etc

当语言是LTR语言时,它可以正常工作,但是当我将语言更改为RTL语言时,画布无法显示

0 个答案:

没有答案