Setting color of a Paint object in custom view
I am trying to make a custom view and have declared the styled attributes
like the below:-
<resources>
<declare-styleable name="NewCircleView">
<attr name="radius" format="integer"/>
<attr name="circlecolor" format="color"/>
</declare-styleable>
</resources>
in the constructor of the customview , these values are obtained like below:-
circleradius=a.getInt(R.styleable.NewCircleView_radius, 0);//global var
circlecolor=a.getColor(R.styleable.NewCircleView_circlecolor,
0);//global var and a is the typed array
The view is used by declaring the xml as below:-
<com.customviews.NewCircleView
android:layout_below="@id/thetext"
android:layout_width="match_parent"
android:layout_height="fill_parent"
app:radius="10000"
app:circlecolor="@color/black"<!--this is defined in colors.xml
/>
In the custom view when i set the paint object as :-
thePaintObj.setColor(circlecolor);//circlecolor logs to an integer as
expected
I dont get the color-"black" defined in the xml
however when i set the color as
thePaintObj.setColor(Color.GRAY)
I get the color in the view
Can someone tell me what would I be doing wrong ?
(N.B:-If you want me to post more code , please let me know)
No comments:
Post a Comment