zoukankan      html  css  js  c++  java
  • 利用xml文件绘制圆角边框,三角形

    1.绘制圆角边框

    <?xml version="1.0" encoding="UTF-8"?>
    <shape xmlns:android="http://schemas.android.com/apk/res/android"
        android:shape="rectangle">
        <stroke
            android:width="2dp"
            android:color="#000fff" />
        <!--设置边框线宽度和颜色!-->
    
        <solid android:color="#000000" />
        <!--设置内容填充色!-->
        <corners android:radius="10dp"
           />
        <!--设置角度!-->
    </shape>
    

    效果图:

    使用方式:为控件设置android:background="xml文件名"
    也可利用

     android:topLeftRadius=""
            android:topRightRadius=""
            android:bottomLeftRadius=""
            android:bottomRightRadius=""
    

    为四个角分别设置角度。

    2.绘制三角形

    Vector图片

    <vector xmlns:android="http://schemas.android.com/apk/res/android"
        android:width="158dp"
        android:height="64dp"
        android:viewportWidth="24"
        android:viewportHeight="14">
        <path
            android:fillColor="#99000000"
            android:pathData="M7,14l5,-5 5,5z" />
    </vector>
    

    效果图:

    这是AS自带的vector正三角,我更改了一下数值变为等腰且下移。
    width,height代表控件实际的尺寸。
    viewportWidth代表把width分成了24份,同理viewportHeight把height分成了14份,它相当于我们的视图窗口。
    pathData数值就是依靠它来画出我们的三角形。
    解析一下:
    坐标向右为正,向下为正。
    第一个点(7,14),点(0,0)移动至坐标(7,14)起始点。(viewportHeight为14,说明现在初始点移动到了底部)
    第二个点(5,-5),它是相对于第一个点向右移动5个单位,向上移动5个单位。
    第三个点(5,5),它是相对于第二个点向右移动5个单位,向下移动5个单位。
    M是移动,l是画线,z是形成闭合,这样一个等腰三角形就画出来了。

  • 相关阅读:
    gtest(C++单元测试框架)
    tinyXML入门
    笔记 解决vue3动态绑定本地图片失效问题
    面试技巧
    vuex 状态管理
    插槽的使用
    Vue-router 路由
    Vue组件
    (转)JS 常用 DOM
    9-26
  • 原文地址:https://www.cnblogs.com/dearnotes/p/13698060.html
Copyright © 2011-2022 走看看