整个观对角线

编程入门 行业动态 更新时间:2024-10-28 10:26:33
本文介绍了整个观对角线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

根据一些条件,我要切成斜列表单元格。对于这个我已经使用这个code对角线绘制的图像:

Based on some condition, I have to diagonally cut the list cell. For this I have made diagonal drawable image using this code:

diagonal_line.xml

<?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="schemas.android/apk/res/android" > <item android:top="0dp" android:bottom="0dp" > <rotate android:fromDegrees="315" android:toDegrees="315" android:pivotX="0%" android:pivotY="0%" > <shape android:shape="line" > <stroke android:width="10dp" android:color="@color/grey" /> </shape> </rotate> </item> </layer-list>

在列表单元格的XML它被用作:

In list cell's xml it is used as:

<ImageView android:layout_height="match_parent" android:layout_width="match_parent" android:background="@drawable/diagonal_line" android:layerType="software" android:scaleType="fitXY" />

这对角线出现在单元格的XML的图形视图,但是没有列表充气后。现在它的visbility是独立于任何条件,即它是知名度始终是真实的。

This diagonal line appears in graphics view of cell's xml but not after list is inflated. For now its visbility is independent of any condition i.e. it is visibility is always true.

任何想法,问题是什么?

Any idea where the issue is?

推荐答案

有关对角线自定义的看法是:

Custom view for diagonal line is:

import android.content.Context; import android.content.res.Resources; import android.graphics.Canvas; import android.graphics.Paint; import android.util.AttributeSet; import android.view.View; public class DiagonalLineView extends View { private int dividerColor; private Paint paint; public DiagonalLineView(Context context) { super(context); init(context); } public DiagonalLineView(Context context, AttributeSet attrs) { super(context, attrs); init(context); } public DiagonalLineView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); init(context); } private void init(Context context) { Resources resources = context.getResources(); dividerColor = resources.getColor(R.color.grey); paint = new Paint(); paint.setAntiAlias(true); paint.setColor(dividerColor); paint.setStrokeWidth(resources.getDimension(R.dimen.vertical_divider_width)); } @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); canvas.drawLine(0, getHeight(), getWidth(), 0, paint); } }

这为我工作。

更多推荐

整个观对角线

本文发布于:2023-11-30 10:21:40,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1649637.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:对角线

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!