我想要一个宽度为fill_parent的ImageView,高度应该与宽度相同。我不确定在xml中是否有一种方式可以指定这个,是创建自己的ImageView派生类的唯一选项吗?
public class MyImageView extends ImageView {
// Just return whatever the current width is?
private int measureHeight(int measureSpec) {
return getWidth();
}
}
这是正确的方法吗?还有其他选项吗?(我不确定上面的方法是否正确,例如我不确定宽度测量是否在高度测量之前进行)
谢谢