I have defined XML for gradient.
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<gradient
android:startColor="#9acd32"
android:endColor="#ffffff"
android:angle="180"
/>
i want to use gradient in following code.
XYRegionFormatter regionFormatter3 = new XYRegionFormatter(Color.BLUE);
instead of Color.BLUE
How to use it?
and this i am using in LineAndPointFormatter lpFormatter1;
lpFormatter1.addRegion(new RectRegion(0, 4, Double.NEGATIVEINFINITY, Double.POSITIVEINFINITY, "R3"), regionFormatter3) - Ravi Ranjan 2012-04-04 05:38
try this...
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient android:type="radial" android:gradientRadius="250"
android:startColor="#E9E9E9" android:endColor="#D4D4D4" />
</shape>
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.atos.range/com.atos.range.Range}: android.content.res.Resources$NotFoundException: File res/drawable/shape.xml from color state list resource ID #0x7f020007
But there is entry of shape.xml in R.jav - Ravi Ranjan 2012-04-04 06:04
Try this:
XYRegionFormatter regionFormatter3 = new XYRegionFormatter(getResources().getColor(R.color.<xml_file_name>));
Edit:
I realized it needs a Color attribute, while this line tries to cross reference it to a drawable, which is wrong. The gradient actually forms a drawable, while the XYRegionFormatter
needs a Color attribute. Therefore, the gradient drawable cannot be used in this case. There are no other possibilities available in the code to use gradient as color attribute, afaik.
Also, since the XYRegionFormatter
does not define any ways to use a Drawable(), or even Paint() for that matter, it presently does not seem possible to use a gradient for the scenario you are looking at.
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.atos.range/com.atos.range.Range}: android.content.res.Resources$NotFoundException: File res/drawable/shape.xml from color state list resource ID #0x7f020007
But there is entry of shape.xml in R.jav - Ravi Ranjan 2012-04-04 06:04
You should do some thing like this .
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:startColor="#9acd32"
android:endColor="#ffffff"
android:angle="180"
/>
</shape>
this xml will be in your res/drawable with name like shape.xml
Now in you code you can pass this like below code.
XYRegionFormatter regionFormatter3 = new XYRegionFormatter(getResources().getDrawable(R.drawable.shape));
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.atos.range/com.atos.range.Range}: android.content.res.Resources$NotFoundException: File res/drawable/shape.xml from color state list resource ID #0x7f020007
But there is entry of shape.xml in R.jav - Ravi Ranjan 2012-04-04 06:04
XYRegionFormatter
this class - Herry 2012-04-04 06:06
View.setBackgroundResource();
Herry 2012-04-04 06:09
getResources().getDrawable(R.drawable.shape)
this line return some value not null - Herry 2012-04-04 06:11