0

I'm starting to experiment with the MotionLayout and in my scenario, I actually have a CircularProgressIndicator that I want to redimension.

Motion Scene 1:

enter image description here

Motion Scene 2:

enter image description here

Now, the way CircularProgressIndicator works is that it has 2 attributes that we can define to change the progress indicator:

app:indicatorSize="85dp"
app:trackThickness="17dp"

I am unable to understand how to change these values during the motion scene. For example, at the "Collapsed" state I would like these to be:

app:indicatorSize="40dp"
app:trackThickness="5dp"

I thought this would be one use case for CustomAttributes but it seems they are predefined in some way and I can't add, let's say, "new" ones. As I tried this was what happened:

enter image description here

So, question is: How can I change these attributes ?

Peddro
  • 1,105
  • 2
  • 9
  • 19

1 Answers1

1

CustomAttributes access the set Methods of the View subclass you are operating on.

for example if the view has setText(String str)

Then you can access

The GUI above uses reflection for find all Methods that start with "set"

So in the case of CircularProgressIndicator looking at its methods it has "setTrackThickness(int trackThickness)" and "setIndicatorSize(int indicatorSize)"

So you would use trackThickness and integer Unfortunately Dimension is a float so you can only use

<CustomAttribute app:attributeName="trackThickness " app:customIntegerValue="3" />

More importantly interpolation would look bad because in reality you can only set TrackThickness() to 1,2,3,4 etc. So it will be quantized.

hoford
  • 4,918
  • 2
  • 19
  • 19
  • You are correct. My problem was that I was setting it as a dimension. Unfortunately, it still does not work, but now I think it's because of how this specific layout is implemented. – Peddro May 14 '21 at 09:51