skip to Main Content

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.

enter image description here

2

Answers


  1. 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.

    Login or Signup to reply.
  2. 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. 😉

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search