相关疑难解决方法(0)

将视图层次结构旋转90度

我正在研究FrameLayout的子类,它应该将其所有子项旋转90度.我这样做是为了克服Android 2.1及以下版本中仅限风景的相机限制,让活动处于风景中,但将我的相机叠加放入此framelayout叠加层,使其看起来像是肖像(这就是如何Layar做到了)为了做到这一点,我正在调整Jeff Sharkey的代码来旋转视图.我的问题是我可以旋转Framelayout,但我不能调整它以匹配新的尺寸.所以在我的g1上,而不是在景观中480x320相机视图上的320x480纵向视图,我在中间看到一个320x320的盒子,显示我的纵向视图,两侧被切掉.

到目前为止,这是我的代码:

public class RotateLayout extends FrameLayout {
    private Matrix mForward = new Matrix();
    private Matrix mReverse = new Matrix();
    private float[] mTemp = new float[2];

    public RotateLayout(Context context) {
        super(context);
    }

    public RotateLayout(Context context, AttributeSet attrs) {
        super(context, attrs);

    }


    /* (non-Javadoc)
     * @see android.widget.FrameLayout#onMeasure(int, int)
     */
    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
        //This didn't work:
        //super.onMeasure(heightMeasureSpec, widthMeasureSpec);
    }

    /* (non-Javadoc)
     * @see android.widget.FrameLayout#onSizeChanged(int, int, int, int)
     */
    @Override …
Run Code Online (Sandbox Code Playgroud)

animation android android-widget android-layout

35
推荐指数
2
解决办法
4万
查看次数