1
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/go"
android:text="go"
/>

我想在线性布局的按钮下方加一个圆圈,怎么做?main.xml需要做哪些改动?

public class SomeActivity extends Activity {
 private Button checkButton;
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
        start();
        }

        private void start() {
            checkButton=(Button)findViewById(R.id.go);
            checkButton.setOnClickListener(new View.OnClickListener(){
                public void onClick(View v){
                        }
                    });
}

onClick方法需要填写什么?

4

1 回答 1

4

制作位图,然后在其画布上绘制,然后将此位图添加到图像视图中。

创建位图:

Bitmap bmp = Bitmap.createBitmap(100, 100,  Bitmap.Config.ARGB_8888);

Paint paint = new Paint();
paint.setAntiAlias(true);
paint.setColor(Color.BLUE);

Canvas c = new Canvas(bmp);
c.drawCircle(60,50,25, paint);

设置为图像视图

img.setImageBitmap(bmp);
于 2013-03-27T10:13:14.820 回答