在xml布局中旋转SurfaceView

时间:2015-02-08 22:38:22

标签: android xml rotation surfaceview

如何将布局文件中的自定义SurfaceView旋转180度?

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
   android:orientation="vertical" 
   android:layout_width="match_parent"
   android:layout_height="match_parent">
      <package.CustomSurfaceView
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:rotation="180"
      />
</LinearLayout>

毋庸置疑,上述代码无效。

1 个答案:

答案 0 :(得分:0)

你无法通过XML(就像你注意到的那样),

最好的选择是在绘图之前在画布上进行,如下所示:

canvas.rotate(180f);