在自定义LinearLayout周围绘制边框

时间:2013-03-28 01:40:24

标签: android android-linearlayout android-view android-custom-view

这是我的屏幕布局的简要说明。

<CustomLayout>
    <CardView>
        <CustomTextView />
        <CustomTextView />
        <CustomTextView />
    </CardView>
    <CustomTextView />
    <CustomTextView />
</CustomLayout>

我将其编码为CardView extends LinearLayoutCustomTextView extends TextView。除了我想在CardView的底部和第二个CustomTextView的底部绘制边框线以外,一切正常。为此,我对CardViewCustomTextView使用相同的方法:

@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    getLocalVisibleRect(mRect);
    if (mDrawBottomBorder)
        canvas.drawLine(mRect.left, mRect.bottom, mRect.right, mRect.bottom, mBorderPaint);
}

在这两种情况下都会调用该方法,即CardViewCustomTextView,但它不会为我的CardView绘制边框!我怀疑是因为它extends LinearLayout而不是TextView但是它不应该起作用吗?

1 个答案:

答案 0 :(得分:0)

好的我明白了。我的CustomTextView布局中的第3个CardView覆盖了其下方的边框,因此该线条不可见。

相关问题