我为方形布局创建了自己的类:
public class SquareLayout extends LinearLayout{
    public SquareLayout(Context context) {
        super(context);
    }
    public SquareLayout(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }
    public SquareLayout(Context context, AttributeSet attrs) {
        super(context, attrs);
    }
    @Override public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        int width = MeasureSpec.getSize(widthMeasureSpec);
        int height = MeasureSpec.getSize(heightMeasureSpec);
        int size = width > height ? height : width;
        setMeasuredDimension(size, size);
    }
然后,在我的 xml 中:
...
        <com.myApp.SquareLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_gravity="center_horizontal"
            android:orientation="horizontal" >
            <ImageView
                android:id="@+id/cellImageView"
                android:adjustViewBounds="true"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="2dp"
                android:padding="2dp"
                android:scaleType="centerCrop"
                android:src="@drawable/image" />
        </com.myApp.SquareLayout>
...
在我的 java 代码中没有更多的东西。但相反,如果我的布局和图像,我只看到一个白色矩形......
我错了什么?