In my program I dynamically create round buttons:
for (i = 0; i < k; i ++) { xPosition = 50; for (j = 0; j < k; j ++) { roundButton = (Button) LayoutInflater.from(this).inflate(R.layout.button, null); roundButton.setId(i); roundButton.setX(xPosition); roundButton.setY(yPosition); roundButton.setBackgroundResource(R.drawable.shape); xPosition += step; roundButton.setLayoutParams(layoutParams); llMain.addView(roundButton); } yPosition += step; } The button itself is described in button.xml
android:background="@drawable/shape" As you can see, the background property refers to shape.xml
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:innerRadius="20dp" android:shape="ring" android:thickness="1dp" android:useLevel="false"> <solid android:color="#cccaca"> </solid> </shape> I need to dynamically change the innerRadius property described in shape.xml .
How to do it?