80,349
社区成员
发帖
与我相关
我的任务
分享
public class ReviewView extends SurfaceView implements SurfaceHolder.Callback
{
public SurfaceHolder surfaceHolder;
Context context;
public ReviewView(Context context)
{
super(context);
this.context=context;
this.surfaceHolder=this.getHolder();
this.surfaceHolder.addCallback(this);
}
...
public void surfaceCreated(SurfaceHolder holder)
{
}
public void Draw()
{
Canvas canvas=this.surfaceHolder.lockCanvas();
canvas.drawColor(Color.GREEN);
this.surfaceHolder.unlockCanvasAndPost(canvas);
}
}
int height=2000;
int width =2000;
this.reviewView=new ReviewView(this);
this.reviewView.getHolder().setFixedSize(width, height);
scrollView.addView(reviewView);
public void test_onClick(View view)
{
try
{
reviewView.Draw();
}
catch(Exception e)
{
}
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="test_onClick"
android:text="测试"
/>
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<HorizontalScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/ReviewActivity_HScrollView"
>
</HorizontalScrollView>
</ScrollView>
</LinearLayout>