Skip to content

Commit 39b0846

Browse files
authored
Revert "hzuapps#5 hzuapps#67 第五次作业 "
1 parent b86578c commit 39b0846

File tree

2 files changed

+10
-34
lines changed

2 files changed

+10
-34
lines changed

AndroidLabs/app/src/main/java/edu/hzuapps/androidlabs/homeworks/net1414080903108/Net1414080903108Activity.java

+4-29
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,17 @@
11
package edu.hzuapps.androidlabs.homeworks.net1414080903108;
22

3-
import android.content.Intent;
43
import android.graphics.Bitmap;
54
import android.graphics.Canvas;
65
import android.graphics.Color;
76
import android.graphics.Matrix;
87
import android.graphics.Paint;
9-
import android.net.Uri;
10-
import android.os.Environment;
118
import android.support.v7.app.AppCompatActivity;
129
import android.os.Bundle;
1310
import android.view.MotionEvent;
1411
import android.view.View;
1512
import android.widget.ImageView;
16-
import android.widget.Toast;
13+
1714
import com.example.myapplication.R;
18-
import java.io.File;
19-
import java.io.FileOutputStream;
20-
import java.io.OutputStream;
2115

2216
public class Net1414080903108Activity extends AppCompatActivity {
2317
private ImageView iv;
@@ -31,7 +25,7 @@ protected void onCreate(Bundle savedInstanceState) {
3125
setContentView(R.layout.activity_net1414080903108);
3226
this.iv = (ImageView) this.findViewById(R.id.iv);
3327
// 创建一张空白图片
34-
baseBitmap = Bitmap.createBitmap(1200, 1600, Bitmap.Config.ARGB_8888);
28+
baseBitmap = Bitmap.createBitmap(480, 640, Bitmap.Config.ARGB_8888);
3529
// 创建一张画布
3630
canvas = new Canvas(baseBitmap);
3731
// 画布背景为白色
@@ -41,7 +35,7 @@ protected void onCreate(Bundle savedInstanceState) {
4135
// 画笔颜色为黑色
4236
paint.setColor(Color.BLACK );
4337
// 宽度5个像素
44-
paint.setStrokeWidth(10);
38+
paint.setStrokeWidth(8);
4539
// 先将白色背景画上
4640
canvas.drawBitmap(baseBitmap, new Matrix(), paint);
4741
iv.setImageBitmap(baseBitmap);
@@ -74,23 +68,4 @@ public boolean onTouch(View v, MotionEvent event) {
7468
}
7569
});
7670
}
77-
78-
public void save(View view) {
79-
try {
80-
File file = new File(Environment.getExternalStorageDirectory(),
81-
System.currentTimeMillis() + ".jpg");
82-
OutputStream stream = new FileOutputStream(file);
83-
baseBitmap.compress(Bitmap.CompressFormat.JPEG, 100, stream);
84-
stream.close();
85-
Intent intent = new Intent();
86-
intent.setAction(Intent.ACTION_MEDIA_MOUNTED);
87-
intent.setData(Uri.fromFile(Environment
88-
.getExternalStorageDirectory()));
89-
sendBroadcast(intent);
90-
} catch (Exception e) {
91-
Toast.makeText(this, "保存图片成功", 0).show();
92-
93-
e.printStackTrace();
94-
}
95-
}
96-
}
71+
}

AndroidLabs/app/src/main/res/layout/activity_net1414080903108.xml

+6-5
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@
1717

1818
<Button
1919
android:text="保存"
20-
android:onClick="save"
21-
android:layout_width="match_parent"
20+
android:layout_width="wrap_content"
2221
android:layout_height="wrap_content"
23-
android:id="@+id/button1"
22+
android:id="@+id/button2"
2423
android:layout_marginRight="49dp"
2524
android:layout_marginEnd="49dp"
2625
android:layout_alignParentBottom="true"
27-
android:layout_toLeftOf="@+id/button" />
26+
android:layout_toLeftOf="@+id/button"
27+
android:layout_toStartOf="@+id/button" />
2828

2929
<Button
3030
android:text="清除"
@@ -36,4 +36,5 @@
3636
android:layout_alignParentBottom="true"
3737
android:layout_alignParentRight="true"
3838
android:layout_alignParentEnd="true" />
39-
</RelativeLayout>
39+
</RelativeLayout>
40+

0 commit comments

Comments
 (0)