Java 是否有可能在循环中设置多个ImageView的比例?

Java 是否有可能在循环中设置多个ImageView的比例?,java,android,android-layout,Java,Android,Android Layout,我想将多个ImageView的ScaleX和ScaleY设置为相同的值。 是否有可能在循环中进行 for(int i=1;i<=9;i++){ String img = "imageview" + i; (imageview + i).setScaleX(x); } // x is the variable for(inti=1;i我还没有测试,但这应该可以工作 您可以为每个ImageView设置一个标记,确保每个标记都递增,例如: //first ImageView android:

我想将多个ImageView的ScaleX和ScaleY设置为相同的值。 是否有可能在循环中进行

for(int i=1;i<=9;i++){
String img = "imageview" + i;
(imageview + i).setScaleX(x);
}
// x is the variable

for(inti=1;i我还没有测试,但这应该可以工作


您可以为每个
ImageView
设置一个标记,确保每个标记都递增,例如:

//first ImageView
android:tag="@string/one" //one = 1
//second ImageView
android:tag="@string/two" //two = 2
然后在for循环中:

for(int i=1;i<=9;i++){ 
    ImageView img = findViewWithTag(String.valueOf(i)); 
    img.setScaleX(x); 
}

for(inti=1;i我还没有测试,但这应该可以工作


您可以为每个
ImageView
设置一个标记,确保每个标记都递增,例如:

//first ImageView
android:tag="@string/one" //one = 1
//second ImageView
android:tag="@string/two" //two = 2
然后在for循环中:

for(int i=1;i<=9;i++){ 
    ImageView img = findViewWithTag(String.valueOf(i)); 
    img.setScaleX(x); 
}

用于(int i=1;i您想要什么?请描述更多detail@Jasurbek我认为这个问题完美地描述了OP想要实现的目标。你想要什么?描述更多detail@Jasurbek我认为这个问题很好地描述了OP想要实现的目标。我现在正在使用一点其他的程序,这个问题无法解决,所以我想我会手动完成。无论如何,谢谢:我现在正在使用一点其他的程序,它不能通过这个来解决,所以我想我会手动完成。无论如何,谢谢:D