skt
skt

Reputation: 589

How to create progress bar with rounded corners / Edge in Xamarin forms

I need the expert help. I am struggling to create the ProgressBar with rounded corner in Xamarin Form. I have searched on google and found the couple of post by using the layer property ex. "Layer.CornerRadius = 5" but my code does not support it.

How to make a progress bar with rounded corners in Xamarin forms.

(The above example not supported)

How can I create the rounded Edge of the progress bar?

Sample Code (TestControls.xaml usnig XamarinForm):-

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:local="clr-namespace:Test.Mobile"
            xmlns:ffimageloadingsvg="clr-namespace:FFImageLoading.Svg.Forms;assembly=FFImageLoading.Svg.Forms"
             x:Class="Test.Mobile.UI.TestControls">
    <ContentPage.Content>

            <Grid Grid.Column="1"  Margin="0" Padding="0"  BackgroundColor= "LightYellow"  >
                <ProgressBar x:Name="pb_ProgressBar" Margin="70,0,30,0"   Progress="0.0" WidthRequest="300" HeightRequest="20" ProgressColor="DarkSlateBlue" VerticalOptions="Center"  BackgroundColor="AntiqueWhite"></ProgressBar>
            </Grid> 

    </ContentPage.Content>
</ContentPage>

and Code behind file as

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

using Xamarin.Forms;
using Xamarin.Forms.Xaml;

namespace Test.Mobile.UI
{
    [XamlCompilation(XamlCompilationOptions.Compile)]
    public partial class TestControls : ContentPage
    {
        public TestControls ()
        {
            InitializeComponent ();

            Device.BeginInvokeOnMainThread(async () =>
            {
                await pb_ProgressBar.ProgressTo(1.0, 10000, Easing.Linear);
            });
        }         

    }
}

enter image description here

Please help me how to make a progress bar with rounded corners in Xamarin forms?

Upvotes: 2

Views: 891

Answers (1)

York Shen
York Shen

Reputation: 9084

I can not use xmlns:android="schemas.android.com/apk/res/android";. The device android tablet will be use offline and no internet access.

This is not library, you could refer to the question:

Why this line xmlns:android=“http://schemas.android.com/apk/res/android” must be the first in the layout xml file?

As NitroG42 said, in XML, xmlns declares a Namespace. In fact, when you do:

<LinearLayout android:id>
</LinearLayout>

Instead of calling android:id, the xml will use http://schemas.android.com/apk/res/android:id to be unique. Generally this page doesn't exist (it's a URI, not a URL), but sometimes it is a URL that explains the used namespace.

The namespace has pretty much the same uses as the package name in a Java application.

You could refer to the documentation:

Uniform Resource Identifier (URI)

A Uniform Resource Identifier (URI) is a string of characters which identifies an Internet Resource.

The most common URI is the Uniform Resource Locator (URL) which identifies an Internet domain address. Another, not so common type of URI is the Universal Resource Name (URN).

Upvotes: 0

Related Questions