Share via


How to add border color to a Linearlayout?

Question

Friday, January 8, 2021 7:19 AM

I created a linearlayout with a textview in it and a triangle down to the linearlayout.

```

and the mycorner.xml: 0 19dp #444444 ```

there will be a oval shape with a triangle I want to add a shadow around the oval and down of the triangle. how to add it

the triangle should not be separated with the oval shape. the shadow width can be changed .

thank you.

All replies (4)

Friday, January 8, 2021 12:01 PM

For border width and color you could check the following code

<?xml version="1.0" encoding="UTF-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <corners android:radius="20dp"/> <padding android:left="10dp" android:right="10dp" android:top="10dp" android:bottom="10dp"/> <stroke android:width="1dp" android:color="#aaaaaa"/> </shape>


Tuesday, February 2, 2021 8:19 AM

@lescper I write a oval shape, here is code. <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <!--First shadow--> <item> <shape android:shape="oval"> <solid android:color="#0F000000" /> <corners android:radius="10dp" /> </shape> </item> <!second shadow--> <item android:bottom="1dp" android:left="1dp" android:right="1dp" android:top="1dp"> <shape android:shape="oval"> <solid android:color="@android:color/white"/> <corners android:radius="10dp" /> </shape> </item> </layer-list>

Here is running screenshot.

Could you share triangle.xaml? Do you use vector to draw triangle like following code?

<vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="40dp" android:height="40dp" android:viewportHeight="100" android:viewportWidth="100"> <group android:name="triableGroup"> <path android:name="triangle" android:pathData="m 50,0 l 50,50 -100,0 z" /> </group> </vector>


Xamarin forums are migrating to a new home on Microsoft Q&A! We invite you to post new questions in the Xamarin forums’ new home on Microsoft Q&A! For more information, please refer to this sticky post.


Tuesday, February 2, 2021 9:26 AM

yes the triangle.xml is the code that as yours.


Wednesday, February 3, 2021 6:19 AM

If you have this triangle.png (with showdow) picture, you can use this tool to convert your png to vector path.