How do i draw these kinds custom shape?

余生长醉 提交于 2020-01-16 09:07:10

问题


I have the following design and need to make without using png file if possible. I have done this with the help of png file but i am thinking if there is any other way which is performance centric.

I have done this design with the help of png file

https://pasteboard.co/Is3RtJY.png

How do i draw this myself or use some tool to get this done?


回答1:


Use the following code to create this custom shape bg_top_corners_round.xml and save it in your drawable:

<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/white" />
<corners android:topLeftRadius="16dp" android:topRightRadius="16dp" />
</shape>

Then use this drawable in any of your layout XML files, inside CardView/TextView/ImageView like this:

android:src="@drawable/bg_top_corners_round"



回答2:


PNG images are good for application but, Another option you can use in your application is that you can use webp type images instead of png, which is very smaller in size so, it will help in decreasing the apk file size of the application. In the android studio you can convert png image to webp image. Another best thing you can do is convert png to related vector graphic(SVG) and then import that SVG as drawable. Like for png and webp images you will not needed to add images according to device density but it will be automatically maintained means when the image will be needed it will be drawn according to the device density.

Many websites are available which can help to convert the png to SVG but I prefer https://www.vectorizer.io/



来源:https://stackoverflow.com/questions/57443340/how-do-i-draw-these-kinds-custom-shape

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!