<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方法需要填写哪些内容?
答案 0 :(得分:4)
制作位图,然后在其画布上绘制,然后将此位图添加到imageview,例如。
创建位图:
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);
设置为imageview
img.setImageBitmap(bmp);