CopyPastor

Detecting plagiarism made easy.

Score: 1; Reported for: Exact paragraph match Open both answers

Possible Plagiarism

Plagiarized on 2022-09-16
by R15

Original Post

Original - Posted on 2010-08-16
by Konstantin Burov



            
Present in both answers; Present only in the new answer; Present only in the old answer;

Use `Custom renderer` to apply `border` on `Label` control. Create `class` `ExLabel` in `xamarin.forms` Shared project. Like below
public class ExLabel : Label { public ExLabel() { } }
Now in `android` project implement add `Custom renderer` class and use `ExLabel` there

[assembly: ExportRenderer(typeof(ExLabel), typeof(ExLabelRenderer))] namespace Chemichals.Droid.Renderers { public class ExLabelRenderer : LabelRenderer { Context context; public ExLabelRenderer(Context context) : base(context) { this.context = context; } protected override void OnElementChanged(ElementChangedEventArgs<Label> e) { base.OnElementChanged(e); if (Control != null) { Control.SetBackground(ResourcesCompat.GetDrawable(Resources, Resource.Drawable.BorderLabel, null)); } } } }
Now in `Resource -> Drawable` `folder` add below `BorderLabel.xml` file
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" > <solid android:color="@android:color/white" /> <stroke android:width="1dip" android:color="#66B4E6"/> </shape>
In xamarin forms shared project's `xaml file` use `ExLabel` instead of `Label`, you will see a border on it.

You can set a shape drawable (a rectangle) as background for the view.
<TextView android:text="Some text" android:background="@drawable/back"/>
And rectangle drawable back.xml (put into res/drawable folder):
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" > <solid android:color="@android:color/white" /> <stroke android:width="1dip" android:color="#4fa5d5"/> </shape>
You can use `@android:color/transparent` for the solid color to have a transparent background. You can also use padding to separate the text from the border. for more information see: http://developer.android.com/guide/topics/resources/drawable-resource.html

        
Present in both answers; Present only in the new answer; Present only in the old answer;