Setting the border on only one side of the View?

Could anyone do the equivalent of border-left: on a view? (I want to create a border on only one side of the ImageView.)

+4
source share
4 answers

The trick is to create another view with border dimensions and put the View image next to it ... it's an ugly hack, but the only way I've ever seen it followed

+9
source

I know this is an old question, but thought I'd add an alternative that I found today.

It is also ugly .... but perhaps easier.

I needed to create a panel of four icons on the screen with a separator. What I did was create as a container and within this 4 tag (with inside of them). I set them to the left: 0, 25%, 50% and 75%. Then I set the width of each embedded to 24.8% and set the background color of the container to whatever color I would like in the panel.

Example:

<View id="tb1" bottom="0" height="45dp" width="100%" backgroundColor='#99cc33'> <View height="45dp" left="0" width="24.8%" backgroundColor='#363636'> <ImageView width="40dp" image="/images/trip1.png"/> </View> <View height="45dp" left="25%" width="24.8%" backgroundColor='#363636'> <ImageView width="35dp" image="/images/trip2.png"/> </View> <View height="45dp" left="50%" width="24.8%" backgroundColor='#363636'> <ImageView height="40dp" image="/images/trip3.png"/> </View> <View height="45dp" left="75%" width="25%" backgroundColor='#363636'> <ImageView height="35" image="/images/trip4.png"/> </View> </View> 

/ John

0
source

do a "preview". And make your View color as backgroundColor

0
source

Another ugly hack. Place the background gradient on the bottom. First you need to specify the height, and the line will not be 100% solid, but you will not notice it on the device.

"TextField": { height: 44, backgroundGradient: { type: "linear", startPoint: { x: 0, y: 43 }, endPoint: { x: 0, y: 44 }, colors: [ "white", "#ccc" ] } }

0
source

Source: https://habr.com/ru/post/1344338/


All Articles