xml的小技巧

前端之家收集整理的这篇文章主要介绍了xml的小技巧前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

反编译网易云音乐的时候看到的,

1、使用vector代替箭头图标


<?xml version="1.0" encoding="utf-8"?>
<vector android:height="24.0dip" android:width="24.0dip" android:viewportWidth="24.0" android:viewportHeight="24.0"
  xmlns:android="http://schemas.android.com/apk/res/android">
    <path android:fillColor="@android:color/white" android:pathData="M20,11L7.8,11l5.6,-5.6L12,4l-8,8l8,8l1.4,-1.4L7.8,13L20,11z" />
</vector>

2、删除图标


<?xml version="1.0" encoding="utf-8"?>
<layer-list
  xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <shape android:shape="oval">
            <stroke android:width="2.0dip" android:color="#fff2f4f5" />
            <solid android:color="@android:color/holo_red_light" />
        </shape>
    </item>
    <item android:left="6.0dip" android:top="6.0dip" android:right="6.0dip" android:bottom="6.0dip">
        <rotate android:fromDegrees="-45.0" android:toDegrees="-45.0" android:pivotX="50.0%" android:pivotY="50.0%">
            <shape android:shape="line">
                <stroke android:width="1.0dip" android:color="@android:color/white" />
                <size android:height="14.0dip" android:width="14.0dip" />
            </shape>
        </rotate>
    </item>
    <item android:left="6.0dip" android:top="6.0dip" android:right="6.0dip" android:bottom="6.0dip">
        <rotate android:fromDegrees="45.0" android:toDegrees="45.0" android:pivotX="50.0%" android:pivotY="50.0%">
            <shape android:shape="line">
                <stroke android:width="1.0dip" android:color="@android:color/white" />
                <size android:height="14.0dip" android:width="14.0dip" />
            </shape>
        </rotate>
    </item>
</layer-list>
变种


<?xml version="1.0" encoding="utf-8"?>
<layer-list
  xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <shape android:shape="oval">
            <stroke android:width="2.0dip" android:color="#ff16181c" />
            <solid android:color="#ff902b2b" />
        </shape>
    </item>
    <item android:left="6.0dip" android:top="6.0dip" android:right="6.0dip" android:bottom="6.0dip">
        <rotate android:fromDegrees="-45.0" android:toDegrees="-45.0" android:pivotX="50.0%" android:pivotY="50.0%">
            <shape android:shape="line">
                <stroke android:width="1.0dip" android:color="#ffdec0c0" />
                <size android:height="14.0dip" android:width="14.0dip" />
            </shape>
        </rotate>
    </item>
    <item android:left="6.0dip" android:top="6.0dip" android:right="6.0dip" android:bottom="6.0dip">
        <rotate android:fromDegrees="45.0" android:toDegrees="45.0" android:pivotX="50.0%" android:pivotY="50.0%">
            <shape android:shape="line">
                <stroke android:width="1.0dip" android:color="#ffdec0c0" />
                <size android:height="14.0dip" android:width="14.0dip" />
            </shape>
        </rotate>
    </item>
</layer-list>

3、眼睛图标


<?xml version="1.0" encoding="utf-8"?>
<vector android:height="24.0dip" android:width="24.0dip" android:viewportWidth="24.0" android:viewportHeight="24.0"
  xmlns:android="http://schemas.android.com/apk/res/android">
    <path android:fillColor="@android:color/black" android:pathData="M12,4.5C7,4.5 2.73,7.61 1,12c1.73,4.39 6,7.5 11,7.5s9.27,-3.11 11,-7.5c-1.73,-4.39 -6,-7.5 -11,-7.5zM12,17c-2.76,0 -5,-2.24 -5,-5s2.24,-5 5,2.24 5,5 -2.24,5 -5,5zM12,9c-1.66,0 -3,1.34 -3,3s1.34,3 3,-1.34 3,-3 -1.34,-3 -3,-3z" />
</vector>


4、加号图标
<?xml version="1.0" encoding="utf-8"?>
<vector android:height="24.0dip" android:width="24.0dip" android:viewportWidth="72.0" android:viewportHeight="72.0"
  xmlns:android="http://schemas.android.com/apk/res/android">
    <path android:fillColor="#ff000000" android:pathData="M67.031,33.656H38.344V4.969c0-1.295-1.049-2.344-2.344-2.344c-1.294,0-2.344,1.049-2.344,2.344v28.688H4.969  c-1.294,1.051-2.344,2.344c0,1.295,1.049,2.344,2.344h28.688v28.688c0,2.344  c1.295,2.344-1.049,2.344-2.344V38.344h28.688c1.295,2.344-2.344C69.375,34.707,68.326,33.656,67.031,33.656z" />
</vector>

变种
<?xml version="1.0" encoding="utf-8"?>
<vector android:height="77.0dip" android:width="77.0dip" android:viewportWidth="231.0" android:viewportHeight="231.0"
  xmlns:android="http://schemas.android.com/apk/res/android">
    <path android:fillColor="#ff000000" android:pathData="m152 113h-33v-33c0-1.657-1.343-3-3-3s-3 1.343-3 3v33h-33c-1.657 0-3 1.343-3 3 0 1.657 1.343 3 3 3h33v33c0 1.657 1.343 3 3 3s3-1.343 3-3v-33h33c1.657 0 3-1.343 3-3 0-1.657-1.343-3-3-3" />
    <path android:fillColor="#ff000000" android:pathData="m231 0h-8v2h8v-2m-12 0h-8v2h8v-2m-12 0h-8v2h8v-2m-12 0h-8v2h8v-2m-12 0h-8v2h8v-2m-12 0h-8v2h8v-2m-12 0h-8v2h8v-2m-12 0h-8v2h8v-2m-12 0h-8v2h8v-2m-12 0h-8v2h8v-2m-12 0h-8v2h8v-2m-12 0h-8v2h8v-2m-12 0h-8v2h8v-2m-12 0h-8v2h8v-2m-12 0h-8v2h8v-2m-12 0h-8v2h8v-2m-12 0h-8v2h8v-2m-12 0h-8v2h8v-2m-12 0h-8v2h8v-2m-12 0h-3v2c0 1.392 0 3 0 3h2v-3h1v-2m-1 9h-2v8h2v-8m0 12h-2v8h2v-8m0 12h-2v8h2v-8m0 12h-2v8h2v-8m0 12h-2v8h2v-8m0 12h-2v8h2v-8m0 12h-2v8h2v-8m0 12h-2v8h2v-8m0 12h-2v8h2v-8m0 12h-2v8h2v-8m0 12h-2v8h2v-8m0 12h-2v8h2v-8m0 12h-2v8h2v-8m0 12h-2v8h2v-8m0 12h-2v8h2v-8m0 12h-2v8h2v-8m0 12h-2v8h2v-8m0 12h-2v8h2v-8m0 12h-2v6h2v-2-4m12 4h-8v2h8v-2m12 0h-8v2h8v-2m12 0h-8v2h8v-2m12 0h-8v2h8v-2m12 0h-8v2h8v-2m12 0h-8v2h8v-2m12 0h-8v2h8v-2m12 0h-8v2h8v-2m12 0h-8v2h8v-2m12 0h-8v2h8v-2m12 0h-8v2h8v-2m12 0h-8v2h8v-2m12 0h-8v2h8v-2m12 0h-8v2h8v-2m12 0h-8v2h8v-2m12 0h-8v2h8v-2m12 0h-8v2h8v-2m12 0h-8v2h8v-2m12 0h-8v2h8v-2m1-9h-2v8h2v-8m0-12h-2v8h2v-8m0-12h-2v8h2v-8m0-12h-2v8h2v-8m0-12h-2v8h2v-8m0-12h-2v8h2v-8m0-12h-2v8h2v-8m0-12h-2v8h2v-8m0-12h-2v8h2v-8m0-12h-2v8h2v-8m0-12h-2v8h2v-8m0-12h-2v8h2v-8m0-12h-2v8h2v-8m0-12h-2v8h2v-8m0-12h-2v8h2v-8m0-12h-2v8h2v-8m0-12h-2v8h2v-8m0-12h-2v8h2v-8m0-12h-2v8h2v-8" />
</vector>

5、信息图标
<?xml version="1.0" encoding="utf-8"?>
<vector android:height="16.0dip" android:width="16.0dip" android:viewportWidth="48.0" android:viewportHeight="48.0"
  xmlns:android="http://schemas.android.com/apk/res/android">
    <group>
        <path android:fillColor="#ff000000" android:pathData="M35.5,13.5h-23c-0.829,0-1.5,0.674-1.5,1.5c0,0.828,0.671,1.5,1.5h23c0.828,1.5-0.672,1.5-1.5   C37,14.174,36.328,13.5,35.5,13.5z" />
        <path android:fillColor="#ff000000" android:pathData="M24.5,23.502h-12c-0.829,0.672-1.5,1.498c0,1.502,1.502h12c0.828,1.5-0.674,1.5-1.502   C26,24.174,25.328,23.502,24.5,23.502z" />
        <path android:fillColor="#ff000000" android:pathData="M40,1.498H8c-3.313,0-6,2.689-6,6.004v25C2,35.816,4.687,38.5,8,38.5h3v6.502c0,1.5   c0.435,0.823-0.188,1.097-0.482l12.213-7.52H26h14c3.313,6-2.684,6-5.998v-25C46,4.188,43.313,1.498,40,1.498z M43,31.5   c0,2.209-1.791,4-4,4H26h-0.465c-0.012,0-0.021,0-0.035,0c-0.374,0.005-0.747,0.146-1.033,0.432L20.295,38.5L14,42.375V38.5v-1.498   c0-0.83-0.671-1.502-1.5-1.502H12H9c-2.209,0-4-1.791-4-4V8.502c0-2.211,1.791-4,4-4h30c2.209,4,1.789,4V31.5z" />
    </group>
</vector>

6、编辑
<?xml version="1.0" encoding="utf-8"?>
<vector android:height="64.0dip" android:width="64.0dip" android:viewportWidth="192.0" android:viewportHeight="192.0"
  xmlns:android="http://schemas.android.com/apk/res/android">
    <path android:fillColor="#ff000000" android:pathData="M80.194,114.502c0.84,0.732,2.114,0.644,2.845-0.197l50.964-57.954c0.731-0.842,0.643-2.117-0.197-2.85  c-0.84-0.733-2.113-0.645-2.845,0.197l-50.964,57.953C79.267,112.493,79.354,113.769,80.194,114.502z" />
    <path android:fillColor="#ff000000" android:pathData="M132.5,89c-1.104,0-2,0.896-2,2v40c0,4h-61c-2.209,0-4-1.791-4-4V61c0-2.209,4-4h36  c1.104,2-0.896,2-2s-0.896-2-2-2h-36c-4.418,0-8,3.582-8,8v70c0,4.418,3.582,8h61c4.418,8-3.582,8-8V91  C134.5,89.896,133.604,89,132.5,89z" />
</vector>

7、录像图标
<?xml version="1.0" encoding="utf-8"?>
<vector android:height="40.0dip" android:width="40.0dip" android:viewportWidth="120.0" android:viewportHeight="120.0"
  xmlns:android="http://schemas.android.com/apk/res/android">
    <group>
        <path android:fillColor="#66000000" android:pathData="M60,3C28.57,3,28.57,60c0,31.43,25.57,57,57c31.43,57-25.57,57-57   C117,91.43,60,3z M90.496,72.879c0,6.594-4.928,3.299L71.436,64.975v8.327c0,3.149-2.559,5.699-5.717,5.699H35.222   c-3.158,0-5.718-2.55-5.718-5.699V46.701c0-3.149,2.56-5.702,5.718-5.702h30.497c3.158,5.717,2.553,5.702v8.222   l14.133-11.201c0,4.929-3.293,4.929,3.297L90.496,72.879L90.496,72.879z" />
        <path android:fillColor="#99ffffff" android:pathData="M60,0C26.863,26.862,33.139,26.863,60   c33.137,60-26.861,60-60C120,93.137,0z M60,117C28.57,117,60C3,3c31.43,57   C117,117z" />
        <path android:fillColor="#ffffffff" android:pathData="M85.568,43.722L71.436,54.923v-8.222c0-3.149-2.559-5.702-5.717-5.702H35.222   c-3.158,0-5.718,2.553-5.718,5.702v26.601c0,3.149,2.56,5.699,5.718,5.699h30.497c3.158,5.717-2.55,5.717-5.699v-8.327   l14.133,11.203c4.929,3.295,4.929-3.299,4.929-3.299v-25.86C90.496,40.429,85.568,43.722,43.722z" />
    </group>
</vector>

8、播放图标
<?xml version="1.0" encoding="utf-8"?>
<vector android:height="40.0dip" android:width="40.0dip" android:viewportWidth="120.0" android:viewportHeight="120.0"
  xmlns:android="http://schemas.android.com/apk/res/android">
    <group>
        <path android:fillColor="#66000000" android:pathData="M60,3z M81.9,61.682L49.4,80.848c0,0-3.333,3.334-3.333-0.832v-40c0,0-0.833-4.167,3.333-0.833l32.5,19.166   C81.9,58.348,85.234,60.015,81.9,61.682z" />
        <path android:fillColor="#99ffffff" android:pathData="M60,117z" />
        <path android:fillColor="#ffffffff" android:pathData="M81.9,58.348L49.4,39.182c-4.167-3.333-3.333,0.833-3.333,0.833v39.999c0,4.166,3.333,0.834,0.834   l32.5-19.166C85.234,58.348z" />
    </group>
</vector>


9、刷新图标


<?xml version="1.0" encoding="utf-8"?>
<vector android:height="40.0dip" android:width="40.0dip" android:viewportWidth="120.0" android:viewportHeight="120.0"
  xmlns:android="http://schemas.android.com/apk/res/android">
    <group>
        <path android:fillColor="#66000000" android:pathData="M60,3z M87,86c0,1.104-0.896,2-2,2s-2-0.896-2-2v-6.764C77.497,85.809,69.243,90,90   c-15.617,0-28.404-11.945-29.826-27.189C30.064,62.563,30,62.289,62c0-0.17,0.027-0.332,0.067-0.489   c-0.009-0.172-0.036-0.338-0.042-0.511h0.252c0.346-0.596,0.984-1,1.723-1s1.376,0.404,1.723,1h0.328C34.58,74.893,45.978,86,86   c8.764,16.486-4.354,21.193-11H72c-1.104,0-2-0.896-2-2s0.896-2,2-2h13c1.104,2,0.896,2h0.045   c-0.014,0.029-0.031,0.057-0.045,0.086V86z M88,59c-1.104,0-2-0.896-2-2h-0.188C84.324,44.057,73.344,34,34   c-8.317,0-15.703,3.922-20.461,10H47c1.104,0.895,1.999c0,1.105-0.896,2H34c-1.104,0-2-0.895-2-2V33c0-1.104,2-2   s2,2v9.025C41.471,34.729,50.178,30c15.191,27.715,11.302,29.695,25.951C89.885,56.256,56.614,57   C90,58.104,89.104,59,88,59z" />
        <path android:fillColor="#99ffffff" android:pathData="M60,33.137,60c33.137,60-26.863,60-60   C120,117z" />
        <path android:fillColor="#ffffffff" android:pathData="M60,30c-9.822,0-18.529,4.729-24,12.025V33c0-1.104-0.896-2-2-2s-2,2v13c0,1.105,2h13   c1.104,2-0.895,2-2c0-1.104-0.896-2-2-2h-7.461C44.297,37.922,51.683,34c13.344,24.324,10.057,25.813,23H86   c0,1.104,2s2-0.896,2-2c0-0.387-0.115-0.744-0.305-1.05C87.715,41.302,75.191,30z" />
        <path android:fillColor="#ffffffff" android:pathData="M87,73c0-1.104-0.896-2-2-2H72c-1.104,2s0.896,2h9.193C76.486,81.646,68.764,86   c-14.022,0-25.42-11.107-25.95-25h-0.328c-0.346-0.596-0.984-1-1.723-1c-0.739,0-1.376,0.404-1.723,1h-0.252   c0.006,0.173,0.033,0.339,0.042,0.511C30.027,61.668,61.83,62c0,0.289,0.064,0.563,0.174,0.811   C31.596,78.055,44.383,90c9.243,17.497-4.191,23-10.764V86c0,2-2V73.086   c0.014-0.029,0.031-0.057,0.045-0.086H87z" />
    </group>
</vector>

10、点赞图标


<?xml version="1.0" encoding="utf-8"?>
<vector android:height="16.0dip" android:width="16.0dip" android:viewportWidth="48.0" android:viewportHeight="48.0"
  xmlns:android="http://schemas.android.com/apk/res/android">
    <group>
        <path android:fillColor="#ff000000" android:pathData="M38.789,16.5h-8c0,2-3,2-7c0-3.998-1-8.002-6-8.002h-2c0,0-5,1.004-5,6.004c0,1,8-6,10h-3h-4c0,5v19   c0,5,5h26c0,6,8-5l5-14.002C45.789,27.5,48.789,16.5,38.789,16.5z M10.789,43.502h-4c-0.529,0-1.935,0-2-2v-19   c0-0.529,2-2h4V43.502z M42.918,26.62l-4.934,13.813c-1.227,2.969-5.057,3.064-5.195,3.067h-19v-23   c0.279,0.556-0.039,0.824-0.115c7.339-2.097,8.561-9.306,8.179-13.029c0.074-1.943,1.634-2.64,2.367-2.859h1.63   c1.337,5.002c0,2.985-1.492,5.33-1.496,5.336c-0.613,0.92-0.671,2.104-0.148,3.08c0.521,0.976,1.539,1.584,2.646,1.584h8   c2.616,3.344,0.945,3.583,1.255C43.609,22.36,43.188,25.518,42.918,26.62z" />
    </group>
</vector>


11、相机图标
<?xml version="1.0" encoding="utf-8"?>
<vector android:height="51.0dip" android:width="64.0dip" android:viewportWidth="192.0" android:viewportHeight="153.0"
  xmlns:android="http://schemas.android.com/apk/res/android">
    <path android:fillColor="#d9000000" android:pathData="M36,46c4.418,8s-3.582,8-8,8c-4.418,0-8-3.582-8-8  S31.582,46,36,46z" />
    <group>
        <path android:fillColor="#ff000000" android:pathData="M96,57c15.439,28,12.561,28s-12.561,28-28,28s-28-12.561-28-28S80.561,96,57 M96,50c-19.33,0-35,15.67-35,35   s15.67,35,35s35-15.67,35-35S115.33,50,50L96,50z" />
    </group>
    <group>
        <path android:fillColor="#ff000000" android:pathData="M122.678,8c0.012,0.002,1.213,0.276,3.7,4.388l0.078,0.13l0.085,0.126l8.813,13.235L137.431,29h3.749h34.148   c4.781,8.672,3.929,8.758v98.484c0,4.829-3.891,8.758-8.672,8.758H16.672C11.89,145,141.071,136.242V37.758   C8,32.929,11.89,29,16.672,29H51.35h4.121l2-3.604l7.344-13.235l0.068-0.124l0.064-0.126c1.312-2.609,2.987-3.839,3.44-3.911   h54.286H122.678 M122.674,1H68.388c-4.283,0-7.839,4.077-9.694,7.765L51.35,22H16.672C8.017,22,29.055,37.758v98.484   C1,144.945,8.017,152,152h158.656c8.655,15.672-7.055,15.672-15.758V37.758C191,183.983,175.328,22H141.18   l-8.813-13.235C129.988,4.833,126.957,122.674,1L122.674,1z" />
    </group>
</vector>

12、垃圾桶图标
<?xml version="1.0" encoding="utf-8"?>
<vector android:height="16.0dip" android:width="16.0dip" android:viewportWidth="48.0" android:viewportHeight="48.0"
  xmlns:android="http://schemas.android.com/apk/res/android">
    <group>
        <path android:fillColor="#ff000000" android:pathData="M32,39.5c0.828,1.5-1.5V17c0-0.828-0.672-1.5-1.5-1.5s-1.5,1.5v21C30.5,38.828,31.172,39.5,32,39.5z   " />
        <path android:fillColor="#ff000000" android:pathData="M24,39.5c0.829,1.5-1.5V17c0-0.828-0.671-1.5-1.5-1.5s-1.5,1.5v21C22.5,23.171,24,39.5z   " />
        <path android:fillColor="#ff000000" android:pathData="M16,1.5v21C14.5,15.171,16,39.5z   " />
        <path android:fillColor="#ff000000" android:pathData="M45,8.5h-7.5v-1c0-3.313-2.688-6-6-6h-15c-3.313,2.687-6,6v1H3c-0.829,1.5s0.671,1.5h3.5v29   c0,3.313,2.686,6h23c3.313,6-2.688,6-6v-29H45c0.828,1.5-1.5S45.828,8.5,45,8.5z M13.5,7.5c0-1.657,1.343-3,3-3   h15c1.656,1.343,3v1h-21V7.5z M38.5,40.5c0,1.657-1.344,3-3,3h-23c-1.657,0-3-1.343-3-3v-29h29V40.5z" />
    </group>
</vector>

猜你在找的XML相关文章