user4945896
user4945896

Reputation:

Adding custom attribute to a view

I'm using a libary for creating a donut shaped pie chart.

https://www.numetriclabz.com/donut-chart-tutorial-using-numandroidcharts-library-tutorial/

In this provided tutorial under step 4 there is a custom attribute called custom:pieInnerCircleRatio being added to the donut chart item. However there is no specific explanation written, on how that is done.

Upvotes: 2

Views: 1353

Answers (3)

nipun.birla
nipun.birla

Reputation: 719

Add following line to your parent element in xml :

xmlns:custom="http://schemas.android.com/apk/res-auto"

Upvotes: 0

Code-Apprentice
Code-Apprentice

Reputation: 83567

Step 4 shows how to use the custom attribute. Unfortunately, the code snippets include literal HTML tags and entities. Here is a translated version:

<com.numetriclabz.numandroidcharts.PieChart
           android:layout_width="match_parent"
           android:layout_height="0dp"
           android:layout_weight="1"
           android:layout_margin="10dp"
           android:id="@+id/piegraph"
           custom:pieInnerCircleRatio="128"/>

Upvotes: 0

Distwo
Distwo

Reputation: 11749

This link will guide you: https://developer.android.com/training/custom-views/create-view.html

You need to define attrs.xml file as explained in the Define Custom Attributes section.

Upvotes: 1

Related Questions