User Interface (UI) is one of the most important part of any software development. In PSLab Android App while developing the UI, custom borders are used for various widgets and layouts. This makes the UI look more appealing and widgets and layouts look more highlighted.
In Android, we can do a range of border customization. We can make border rounded, define its thickness and even change its color. Let’s see how to achieve this.
First, go to drawable folder in the tree view on the left size of the Android studio. Then go to new and click on Drawable resource file.
Then a New Resource File dialog box will appear. Type the filename and then click OK.
After this, a new XML file is created. Now we can write the code for creating custom borders. For this, we have to define few elements.
Shape Drawables allows defining background, borders, and gradients for the Views.
Here we are setting the background color of the widget/layout to which the border is applied to.
Now we are applying the 3dip width to the border and set its color. This shape requires the <stroke> element to define the width and color of the line.
In order to make the corners of the border round, <corner> element is used to define the radius of the corners. We are taking it to be 10dip.
The padding is expressed in pixels for the left, top, right and bottom parts of the view. Padding is used to offset the content of the view by a specific number of pixels.
After applying this border on a layout we get the following results.
Similarly making following changes in the element values help us to make border for the Text View
Logical Analyzer Activity