Linear Scale not rendered when loaded inside Custom Adapter in a fragment

Hi,

I'm using SfLinearGauge in RecyclerView.Adapter's view.
RecyclerView items are loaded correctly, issue is LinearScale and LinearRanges are not rendered at all. I can see SfLinearGauge with right background color, but not its children.

SfLinearGauge is added to row.xaml.
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:padding="8dp"
    android:minWidth="25px"
    android:minHeight="25px"
    android:background="?android:attr/selectableItemBackground"
    android:id="@+id/relTestRow">
  
 
       android:id="@+id/sfTestGauge"
       android:layout_width="match_parent"
       android:layout_height="wrap_content">
 

LinearScale is initialized on RecyclerView OnCreateViewHolder.

 public override RecyclerView.ViewHolder OnCreateViewHolder(ViewGroup viewGroup, int position)
        {
            var view = LayoutInflater.From(viewGroup.Context).Inflate(Resource.Layout.row, viewGroup, false);

            var TestGaugeGauge = view.FindViewById(Resource.Id.sfTestGauge);
            TestGaugeGauge.SetOrientation(SfLinearGauge.Orientation.Horizontal);
            TestGaugeGauge.SetBackgroundColor(Color.LightBlue);
           
            LinearScale linearScale = new LinearScale();
            linearScale.ScaleBarColor = Color.ParseColor("#e0e0e0");
            linearScale.LabelColor = Color.ParseColor("#424242");
            linearScale.MajorTickSettings.StrokeWidth = 1;
            linearScale.MinorTickSettings.StrokeWidth = 1;
            linearScale.MajorTickSettings.Length = 20;
            linearScale.MajorTickSettings.Color = Color.Gray;
            linearScale.MinorTickSettings.Color = Color.Gray;
            linearScale.MinorTickSettings.Length = 10;
            LinearRange linearRange = new LinearRange();
            linearRange.StartValue = 0;
            linearRange.EndValue = 60;
            linearRange.Color = Color.ParseColor("#27beb7");
            linearRange.Offset = -20;
            linearRange.StartWidth = 10;
            linearRange.EndWidth = 10;
            linearScale.Ranges.Add(linearRange);
            TestGaugeGauge.Scales.Add(linearScale);
            ViewHolder vh = new ViewHolder(view);
            return vh;
        }

RecycleView is loaded in fragment on OnCreatedView.

    public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            var rootView = inflater.Inflate(Resource.Layout.fragment, container, false);
            rootView.SetTag(rootView.Id, Tag);
            SwipeRefreshContainer = rootView.FindViewById(Resource.Id.swipeContainer);

            RecyclerView = rootView.FindViewById(Resource.Id.recView);
            var layoutManager = new LinearLayoutManager(Activity);
            RecyclerView.SetLayoutManager(layoutManager);

            var adapter = new CustomAdapter(new List() { "A", "A2", "A3"});
            RecyclerView.SetAdapter(adapter);
            return rootView;
        }

Thanks in advance.

3 Replies

SG Sri Gayathri Gopalakrishnan Syncfusion Team April 26, 2018 05:07 PM UTC

 
Hi Anton, 
 
Query: Linear Scale not rendered when loaded inside Custom Adapter in a fragment 
 
We have analysed your query, LinearScale properties haven’t declared properly. We have prepared sample based on your query. RecyclerView is loaded in Fragment. LinearGauge is initialized in RecyclerView. Please download the sample from the below link,  
 
 
Screenshot: 
 
Regards, 
Sri Gayathri. G 



AJ AJ April 27, 2018 10:11 PM UTC

Thank you very much for your prompt response. It works as expected. Thank you.


SG Sri Gayathri Gopalakrishnan Syncfusion Team April 30, 2018 06:28 AM UTC

Hi Anton, 
 
Thanks for your response, we are glad that your query has been resolved and please get back to us if you need any other assistance. 
 
Regards, 
Sri Gayathri. G 


Loader.
Up arrow icon