【发布时间】:2022-09-28 06:54:34
【问题描述】:
我正在尝试在我想用颜色填充的 3 个区域中使用可绘制的鞋垫分割 XML。我已尝试编辑文件,但无法用颜色填充该区域。
我有以下 XML 文件:
<vector xmlns:android=\"http://schemas.android.com/apk/res/android\"
android:width=\"4.44444dp\"
android:height=\"12.4444dp\"
android:viewportWidth=\"400\"
android:viewportHeight=\"1120\">
<path
android:pathData=\"M152,28.21C171.99,31.28 184.34,33.17 203,42.26 241.18,60.87 267.02,93.2 289.69,128 289.69,128 301.55,146 301.55,146 301.55,146 311.3,164 311.3,164 324.56,188.15 336.37,212.4 346.6,238 362.69,278.26 373.25,320.32 380.41,363 380.41,363 387.09,424 387.09,424 387.09,424 388,436 388,436 388,436 388,479 388,479 388,479 387.09,491 387.09,491 385.01,521.27 379.69,551 375.27,581 370.37,614.29 367.2,647.49 364.91,681 364.91,681 364,694 364,694 364,694 363.04,705 363.04,705 363.04,705 363.04,717 363.04,717 363.04,717 362,730 362,730 362,730 362,745 362,745 362,745 361,760 361,760 361,760 361,869 361,869 361,869 362,886 362,886 362,886 363,939 363,939 363,939 362.04,952 362.04,952 359.93,1000.5 344.79,1048.52 300,1074.13 292.36,1078.49 283.46,1082.44 275,1084.86 266.13,1087.4 254.2,1089.89 245,1090 230.5,1090.17 218.05,1089.47 204,1085.28 194.01,1082.3 186.85,1079.09 178,1073.58 143.6,1052.16 129.3,1017.62 123.73,979 123.73,979 121,953 121,953 121,953 120,918 120,918 120,918 121,903 121,903 121,903 121,888 121,888 121,888 122,868 122,868 122,868 123,846 123,846 123,846 124.04,831 124.04,831 124.04,831 124.04,816 124.04,816 124.04,816 125,804 125,804 125,804 125,781 125,781 125,781 126,765 126,765 126,765 126,744 126,744 126,744 125,727 125,727 124.93,680.6 118.93,630.95 107.12,586 90.97,524.56 64.84,480.13 42.2,423 27.1,384.88 17.91,348.79 13.83,308 13.83,308 12,287 12,287 12,287 12,239 12,239 12,239 12.91,227 12.91,227 12.91,227 14.83,200 14.83,200 20.59,142.4 33.12,73.84 88,42.43 96.33,37.66 103.76,34.68 113,32.15 121.71,29.77 133.99,28.01 143,28.21 143,28.21 152,28.21
152,28.21ZM340.28,228M380.13,375\"
android:strokeWidth=\"1\"
android:strokeColor=\"#000000\"/> </vector>
此 XML 文件提供以下输出: https://i.stack.imgur.com/Dhhbp.jpg
我试图将其转换为 JPG 文件以对其进行编辑,因为编辑 svg 对我来说不起作用。之后,我制作了 1 个我想使用的区域,即以下输出: https://i.stack.imgur.com/M3F4Y.jpg
XML 代码(请注意,以下代码是转换后的 jpg 到 svg 文件,我首先编辑了一个 jpg 文件,然后将其转换为 svg 并将该文件作为新的矢量资源插入到 android studio 中):
<vector xmlns:android=\"http://schemas.android.com/apk/res/android\"
android:width=\"1280dp\"
android:height=\"3584dp\"
android:viewportWidth=\"1280\"
android:viewportHeight=\"3584\">
<path
android:pathData=\"M429,89.7C355.1,96.7 297.6,118.4 241.4,160.6C223.8,173.8 199.7,196.8 185,214.5C180.9,
219.4 177.3,223.7 177,224C174.7,226.3 162.7,242.9 155.8,253.5C103.6,332.9 71,436 52.5,580.5C49.4,604.8 46,
638.1 44.5,659C43.7,670.8 41.6,698.9 40,721.3C37,761.6 37,763.2 37,841.5C37,917.9 37.1,922.1 39.5,
949.7C44.9,1011.7 49.2,1045.3 58.4,1097C59.7,1104.4 61.8,1114.5 68.4,1146C72.1,1163.8 83.6,1207.3 91.2,
1232.5C102.5,1270.2 125,1334.2 136.5,1361.5C138.3,1365.9 143.1,1377.4 147.1,1387C158.6,1414.9 161.4,
1421.5 168.8,1438.5C177.4,1458.2 183.5,1472 185.9,1477.4C187,1479.7 189.7,1485.8 192,1491C194.3,
1496.2 198.4,1505.2 201,1511C203.7,1516.8 208.7,1528 212.3,1536C215.8,1544 221.9,1557.5 225.7,1566C229.6,
1574.5 236,1588.9 240,1598C243.9,1607.1 248.7,1617.9 250.5,1622C252.3,1626.1 255.7,1633.9 258,1639.2C261.7,
1647.7 262.6,1649 264.7,1649C266,1649 302.3,1636.2 345.3,1620.6C484.6,1569.9 536.5,1552.3 598,1534.9C687.3,
1509.6 751,1499.7 833,1498.3C910.4,1497.1 981.7,1502.4 1175.4,1524.1C1209.9,1527.9 1238.5,1530.8 1238.8,
1530.5C1239.1,1530.2 1238.9,1529.5 1238.4,1529C1236.9,1527.5 1083.3,1510.5 1012.5,1504.1C977.8,1500.9 952,
1498.9 918,1496.8C890.4,1495.1 807.3,1495.1 786.5,1496.8C667.8,1506.5 588.8,1528.4 325.5,1624.5C301.9,
1633.2 278.4,1641.7 273.5,1643.5L264.4,1646.8L262.6,1642.2C261.5,1639.6 259.2,1634.1 257.4,1630C240.3,
1591.2 226.7,1560.4 224.2,1555C222.6,1551.4 219.3,1544.2 217,1539C214.7,1533.8 211.2,1526.1 209.3,
1522C207.3,1517.9 205.1,1512.9 204.3,1511C203.5,1509.1 199.1,1499.2 194.5,1489C181.7,1460.5 170,1434 170,
1433.5C170,1433.3 168.9,1430.6 167.5,1427.7C166.2,1424.7 163.5,1418.5 161.6,1413.9C159.8,1409.3 157.2,
1403.2 156,1400.5C152.6,1392.8 147.7,1380.8 136.8,1353.5C93.8,1245.6 65.7,1140.1 51.6,1033.5C47.8,
1004.6 46.4,991.6 43,953L39.9,917.6L40.3,833.5C40.6,767.5 41,745.5 42.3,731C43.2,720.8 44.3,705.7 44.9,
697.5C49.9,624.9 54.9,579.6 63.5,527.8C73,471.4 87,412.7 98.9,379.7C100,376.9 102.5,369.8 104.5,
364C114.5,335.8 133.8,294.7 148.5,270.5C179.3,219.7 218.9,178 264.2,148.5C309.6,118.8 353.1,103 413.5,
94.4C428.2,92.3 483.3,91.3 493.3,92.9C540.2,100.4 562.5,104.9 582,110.6C633.4,125.6 690.7,155.4 735.5,
190.5C761.6,210.9 778.2,226 803.5,252.1C848.6,298.5 881.2,342.1 949.8,447C955.3,455.5 960.3,462.9 960.7,
463.5C962.1,465.1 966.4,473 985.5,508.5C991.4,519.5 997,529.8 998,531.5C1010.8,553.4 1055.2,641.6 1069.3,
673C1070.7,676 1075,685.6 1078.9,694.2C1082.8,702.9 1086,710.2 1086,710.5C1086,710.7 1087.1,713.3 1088.4,
716.2C1104,750.4 1129.6,818.1 1144.8,865.5C1155.7,899.5 1157.8,906.6 1169.4,948C1182,993.3 1200.4,
1075.1 1209.9,1129C1211.1,1135.3 1212.9,1145.4 1213.9,1151.5C1215,1157.5 1216.4,1166.8 1216.9,
1172C1217.5,1177.2 1220.2,1202.4 1223,1228C1225.7,1253.6 1228.6,1280.3 1229.5,1287.5C1230.3,1294.6 1231.9,
1309 1233,1319.5C1234.1,1329.9 1235.4,1342.5 1236,1347.5C1239.3,1376.6 1240,1395.5 1240,1462.7C1240,
1522.7 1240.2,1531 1241.5,1531C1242.8,1531 1243,1522.6 1243,1461.2C1243,1388.5 1242.5,1376.3 1238,
1336C1237,1326.4 1234.5,1303.6 1232.5,1285.5C1230.6,1267.3 1228.3,1246.9 1227.5,1240C1226.7,1233.1 1224.4,
1212.9 1222.5,1195C1218.5,1158.1 1218.4,1157.4 1212.9,1127.5C1201.1,1062.5 1189.9,1012.7 1171.9,
945C1168.2,931.2 1162.6,911.8 1156.1,890.5C1122.5,780.1 1071.5,660.7 1007.2,542C961.9,458.2 969.5,
470.9 924.5,403C903.6,371.5 869.7,323.4 866,320C865.7,319.7 861.4,314.3 856.5,308C851.6,301.7 846.6,
295.4 845.4,294L833.4,280C771.7,208.3 707.6,159 632.4,125.7C596.3,109.7 567,101.7 511,92.5C489.7,89 489.2,
89 461,89.2C445.3,89.2 430.9,89.5 429,89.7Z\"
android:strokeWidth=\"1\"
android:fillColor=\"#f0000000\"
android:strokeColor=\"#000000\"/>
我试图用颜色填充这个区域。我使用DrawableCompat.setTint(mInsoleRegion1.getDrawable(), Color.parseColor(color[1])); 来设置和解析我在其他活动中给它的颜色。但它唯一能做的就是给它周围的线条一种颜色,并且不会完全填满中间的空白区域。
我现在的问题是,我需要如何编辑第一个文件,以便它用我想要的颜色填充整个区域?
标签: android-studio android-vectordrawable