如何将布局文件中的自定义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>
不用说,上面的代码不起作用。
您不能通过XML(就像您注意到的那样)、
最好的选择是在绘图前在画布上进行,如下所示:
canvas.rotate(180f);