本文介绍了Android可绘制水平线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用xml来使行像这样?或有某种方法可以做到这一点.

我已经制作了一些可绘制的形状,但是并不是真的想要

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <corners
        android:bottomLeftRadius="30dp"
        android:bottomRightRadius="30dp"
        android:topLeftRadius="0dp"
        android:topRightRadius="0dp" />
    <padding
        android:bottom="0dp"
        android:left="0dp"
        android:right="0dp"
        android:top="0dp" />
    <stroke
        android:width="0.8dp"
        android:color="@color/colorPrimaryDark" />
    <solid android:color="@android:color/transparent" />
</shape>
解决方案

我们也可以为此创建一个可绘制文件.可能对某人有帮助.

可绘制文件:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

<item>
    <shape android:shape="rectangle">
        <solid android:color="@android:color/white" />
    </shape>
</item>

<item>
    <shape android:shape="rectangle">
        <stroke
            android:width="5dp"
            android:color="@android:color/holo_blue_dark" />
        <solid android:color="@android:color/white" />
        <corners android:radius="20dp" />
    </shape>
</item>

<item android:bottom="25dp">
    <shape android:shape="rectangle">
        <stroke
            android:width="2dp"
            android:color="@android:color/white" />
        <solid android:color="@android:color/white" />
    </shape>
</item>

</layer-list>

结果:

Is it possible to make line to be like this with xml? or there's some way to do that..?

I already made some drawable with shape but it's not really like i want

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <corners
        android:bottomLeftRadius="30dp"
        android:bottomRightRadius="30dp"
        android:topLeftRadius="0dp"
        android:topRightRadius="0dp" />
    <padding
        android:bottom="0dp"
        android:left="0dp"
        android:right="0dp"
        android:top="0dp" />
    <stroke
        android:width="0.8dp"
        android:color="@color/colorPrimaryDark" />
    <solid android:color="@android:color/transparent" />
</shape>
解决方案

We can create a drawable file also for this. May be helpful for someone.

Drawable file:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

<item>
    <shape android:shape="rectangle">
        <solid android:color="@android:color/white" />
    </shape>
</item>

<item>
    <shape android:shape="rectangle">
        <stroke
            android:width="5dp"
            android:color="@android:color/holo_blue_dark" />
        <solid android:color="@android:color/white" />
        <corners android:radius="20dp" />
    </shape>
</item>

<item android:bottom="25dp">
    <shape android:shape="rectangle">
        <stroke
            android:width="2dp"
            android:color="@android:color/white" />
        <solid android:color="@android:color/white" />
    </shape>
</item>

</layer-list>

Result :

这篇关于Android可绘制水平线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-30 20:05