How can I add a thick lines across the corners of a view in android studio, something similar to what looks a photo frame. Something like the image given below.
In this case it would be significantly easier if you would just use a vector graphic as a backgound for this view, which then contains your content.
Then you would get the same effect but with a way lower programming effort.
EDIT:
If you want to get this effect using VectorGraphics you can just create that Gaphic with one of the free Vector Graphic tools like Inkscape, Gimp, or if you prefer an Online Version vectr.com. If you created this you can basically just copy it to your project folder and create a resource from it.
You can do this by right-clicking your drawable folder in AndroidStudio and choosing New>ImageResource. AndroidStudio should guide you through the process.
If you have done that, you go to the LayoutFile and switch to XML. Then you can just navigate to your view and add the line:
android:background="@drawable/yourNamehere"
This will make your Vector file, the BackgroudResource of the View.
You can draw lines (in this case, it’s the only option), circles, rectangles & anything you want with custom views. Just give it a try & it will be fun. 😉
2
Answers
In this case it would be significantly easier if you would just use a
vector graphic
as abackgound
for this view, which then contains your content.Then you would get the same effect but with a way lower programming effort.
EDIT:
If you want to get this effect using
VectorGraphics
you can just create that Gaphic with one of the free Vector Graphic tools like Inkscape, Gimp, or if you prefer an Online Version vectr.com. If you created this you can basically just copy it to your project folder and create a resource from it.You can do this by right-clicking your
drawable
folder inAndroidStudio
and choosing New>ImageResource. AndroidStudio should guide you through the process.If you have done that, you go to the LayoutFile and switch to XML. Then you can just navigate to your view and add the line:
This will make your Vector file, the
BackgroudResource
of the View.You can make a custom view and draw thick lines on all corners like shown in the image.
You can then set the view as parent view of your imageview or any view & it will draw the frame around your view.
You can find more about drawing custom views here:
https://blog.mindorks.com/create-your-own-custom-view
You can draw lines (in this case, it’s the only option), circles, rectangles & anything you want with custom views. Just give it a try & it will be fun. 😉