androidd 0.0.1__py3-none-any.whl → 0.0.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- androidd/__init__.py +1 -0
- androidd/cie1/activityCycle/MainActivity.kt +44 -0
- androidd/cie1/activityCycle/activity_main.xml +15 -0
- androidd/cie1/alert/MainActivity.kt +28 -0
- androidd/cie1/alert/activity_main.xml +14 -0
- androidd/cie1/autoCompleteText/MainActivity.kt +19 -0
- androidd/cie1/autoCompleteText/activity_main.xml +14 -0
- androidd/cie1/checkbox/MainActivity.kt +28 -0
- androidd/cie1/checkbox/activity_main.xml +32 -0
- androidd/cie1/customCheckbox/MainActivity.kt +20 -0
- androidd/cie1/customCheckbox/activity_main.xml +22 -0
- androidd/cie1/customCheckbox/custom_checkbox.xml +9 -0
- androidd/cie1/customRadio/MainActivity.kt +22 -0
- androidd/cie1/customRadio/activity_main.xml +28 -0
- androidd/cie1/customRadio/custom_checkbox.xml +9 -0
- androidd/cie1/customToast/MainActivity.kt +35 -0
- androidd/cie1/customToast/activity_main.xml +14 -0
- androidd/cie1/customToast/custom_toast.xml +23 -0
- androidd/cie1/datepicker/MainActivity.kt +31 -0
- androidd/cie1/datepicker/activity_main.xml +20 -0
- androidd/cie1/progressbar/MainActivity.kt +26 -0
- androidd/cie1/progressbar/activity_main.xml +21 -0
- androidd/cie1/radiobutton/MainActivity.kt +25 -0
- androidd/cie1/radiobutton/activity_main.xml +38 -0
- androidd/cie1/timePicker/MainActivity.kt +30 -0
- androidd/cie1/timePicker/activity_main.xml +20 -0
- androidd/cie1/toast/MainActivity.kt +18 -0
- androidd/cie1/toast/activity_main.xml +14 -0
- androidd/cie1/toggle/MainActivity.kt +20 -0
- androidd/cie1/toggle/activity_main.xml +23 -0
- androidd/madbmsj/IMPLICIT and EXPLICIT/Main Activity.kt +31 -0
- androidd/madbmsj/IMPLICIT and EXPLICIT/activity_main.xml +33 -0
- androidd/madbmsj/IMPLICIT and EXPLICIT/second.xml +16 -0
- androidd/madbmsj/IMPLICIT and EXPLICIT/secondactivity.kt +15 -0
- androidd/madbmsj/animation/MainActivity.kt +60 -0
- androidd/madbmsj/animation/activity_main.xml +122 -0
- androidd/madbmsj/animation/bounce.xml +17 -0
- androidd/madbmsj/animation/fad_in.xml +7 -0
- androidd/madbmsj/animation/fade_out.xml +8 -0
- androidd/madbmsj/animation/info.txt +2 -0
- androidd/madbmsj/animation/slide_down.xml +7 -0
- androidd/madbmsj/animation/slide_up.xml +7 -0
- androidd/madbmsj/animation/zoom_in.xml +11 -0
- androidd/madbmsj/animation/zoom_out.xml +11 -0
- androidd/madbmsj/canvas/MainActivity.kt +51 -0
- androidd/madbmsj/canvas/activity_main.xml +18 -0
- androidd/madbmsj/cie1/code.txt +719 -0
- androidd/madbmsj/cie1/sampleQuestion.txt +280 -0
- androidd/madbmsj/cie2/code.txt +1255 -0
- androidd/madbmsj/cie2/ques1/AndroidManifest.xml +2 -0
- androidd/madbmsj/cie2/ques1/MainActivity.kt +45 -0
- androidd/madbmsj/cie2/ques1/SecondActivity.kt +21 -0
- androidd/madbmsj/cie2/ques1/activity_main.xml +19 -0
- androidd/madbmsj/cie2/ques1/activity_second.xml +15 -0
- androidd/madbmsj/cie2/ques1/department_menu.xml +11 -0
- androidd/madbmsj/contextMenu/MainActivity.kt +37 -0
- androidd/madbmsj/contextMenu/activity_main.xml +19 -0
- androidd/madbmsj/contextMenu/info.txt +1 -0
- androidd/madbmsj/contextMenu/menu_main.xml +16 -0
- androidd/madbmsj/database/DatabaseHelper.kt +108 -0
- androidd/madbmsj/database/MainActivity.kt +151 -0
- androidd/madbmsj/database/activity_main.xml +55 -0
- androidd/madbmsj/database/dialog_update_student.xml +22 -0
- androidd/madbmsj/database/info.txt +4 -0
- androidd/madbmsj/datePicker/MainActivity.kt +23 -0
- androidd/madbmsj/datePicker/activity_main.xml +20 -0
- androidd/madbmsj/explicit/activity_main.xml +39 -0
- androidd/madbmsj/explicit/activity_second.xml +15 -0
- androidd/madbmsj/explicit/info.txt +6 -0
- androidd/madbmsj/explicit/mainactivity.kt +32 -0
- androidd/madbmsj/explicit/secondactivity.kt +27 -0
- androidd/madbmsj/fragment/MainActivity.kt +35 -0
- androidd/madbmsj/fragment/activity_main.xml +41 -0
- androidd/madbmsj/fragment/fragment_1.kt +24 -0
- androidd/madbmsj/fragment/fragment_1.xml +16 -0
- androidd/madbmsj/fragment/fragment_2.kt +17 -0
- androidd/madbmsj/fragment/fragnent_2.xml +16 -0
- androidd/madbmsj/fragment/info.txt +1 -0
- androidd/madbmsj/optionsMenu/MainActivity.kt +26 -0
- androidd/madbmsj/optionsMenu/activity_main.xml +18 -0
- androidd/madbmsj/optionsMenu/info.txt +1 -0
- androidd/madbmsj/optionsMenu/menu_main.xml +27 -0
- androidd/madbmsj/package.json +13 -0
- androidd/madbmsj/popMenu/MainActivity.kt +49 -0
- androidd/madbmsj/popMenu/activity_main.xml +19 -0
- androidd/madbmsj/popMenu/info.txt +1 -0
- androidd/madbmsj/popMenu/menu_main.xml +16 -0
- androidd/madbmsj/sharedpref/shared1/activity_main.xml +64 -0
- androidd/madbmsj/sharedpref/shared1/mainactivity.kt +47 -0
- androidd/madbmsj/sharedpref/shared2/activity_main.xml +44 -0
- androidd/madbmsj/sharedpref/shared2/mainactivity.kt +57 -0
- {androidd-0.0.1.dist-info → androidd-0.0.2.dist-info}/METADATA +1 -1
- androidd-0.0.2.dist-info/RECORD +95 -0
- androidd-0.0.2.dist-info/top_level.txt +1 -0
- androidd-0.0.1.dist-info/RECORD +0 -4
- androidd-0.0.1.dist-info/top_level.txt +0 -1
- {androidd-0.0.1.dist-info → androidd-0.0.2.dist-info}/WHEEL +0 -0
@@ -0,0 +1,20 @@
|
|
1
|
+
package com.example.practice
|
2
|
+
|
3
|
+
import android.os.Bundle
|
4
|
+
import android.support.v7.app.AppCompatActivity
|
5
|
+
import android.widget.TextView
|
6
|
+
import android.widget.ToggleButton
|
7
|
+
|
8
|
+
class MainActivity : AppCompatActivity() {
|
9
|
+
override fun onCreate(savedInstanceState: Bundle?) {
|
10
|
+
super.onCreate(savedInstanceState)
|
11
|
+
setContentView(R.layout.activity_main)
|
12
|
+
|
13
|
+
val toggleButton = findViewById<ToggleButton>(R.id.toggleButton)
|
14
|
+
val tvStatus = findViewById<TextView>(R.id.tvStatus)
|
15
|
+
|
16
|
+
toggleButton.setOnCheckedChangeListener { _, isChecked ->
|
17
|
+
tvStatus.text = if (isChecked) "Status: ON" else "Status: OFF"
|
18
|
+
}
|
19
|
+
}
|
20
|
+
}
|
@@ -0,0 +1,23 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
3
|
+
android:layout_width="match_parent"
|
4
|
+
android:layout_height="match_parent"
|
5
|
+
android:orientation="vertical"
|
6
|
+
android:gravity="center"
|
7
|
+
android:padding="24dp">
|
8
|
+
|
9
|
+
<ToggleButton
|
10
|
+
android:id="@+id/toggleButton"
|
11
|
+
android:layout_width="wrap_content"
|
12
|
+
android:layout_height="wrap_content"
|
13
|
+
android:textOn="ON"
|
14
|
+
android:textOff="OFF" />
|
15
|
+
|
16
|
+
<TextView
|
17
|
+
android:id="@+id/tvStatus"
|
18
|
+
android:layout_width="wrap_content"
|
19
|
+
android:layout_height="wrap_content"
|
20
|
+
android:text="Status: OFF"
|
21
|
+
android:layout_marginTop="20dp"
|
22
|
+
android:textSize="18sp"/>
|
23
|
+
</LinearLayout>
|
@@ -0,0 +1,31 @@
|
|
1
|
+
package com.example.implicit
|
2
|
+
|
3
|
+
import android.content.Intent
|
4
|
+
import android.net.Uri
|
5
|
+
import android.os.Bundle
|
6
|
+
import android.support.v7.app.AppCompatActivity
|
7
|
+
import android.widget.Button
|
8
|
+
import android.widget.Toast
|
9
|
+
|
10
|
+
class MainActivity : AppCompatActivity() {
|
11
|
+
override fun onCreate(savedInstanceState: Bundle?) {
|
12
|
+
super.onCreate(savedInstanceState)
|
13
|
+
setContentView(R.layout.activity_main)
|
14
|
+
|
15
|
+
// Explicit Intent
|
16
|
+
val explicitButton = findViewById<Button>(R.id.ExplicitButton)
|
17
|
+
explicitButton.setOnClickListener {
|
18
|
+
Toast.makeText(this, "Explicit Intent", Toast.LENGTH_SHORT).show()
|
19
|
+
val explicitIntent = Intent(this, secondactivity::class.java)
|
20
|
+
startActivity(explicitIntent)
|
21
|
+
}
|
22
|
+
|
23
|
+
// Implicit Intent
|
24
|
+
val url = "https://www.google.com"
|
25
|
+
val ib = findViewById<Button>(R.id.B1)
|
26
|
+
ib.setOnClickListener {
|
27
|
+
val implicitIntent = Intent(Intent.ACTION_VIEW, Uri.parse(url))
|
28
|
+
startActivity(implicitIntent)
|
29
|
+
}
|
30
|
+
}
|
31
|
+
}
|
@@ -0,0 +1,33 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
3
|
+
xmlns:app="http://schemas.android.com/apk/res-auto"
|
4
|
+
xmlns:tools="http://schemas.android.com/tools"
|
5
|
+
android:layout_width="match_parent"
|
6
|
+
android:layout_height="match_parent"
|
7
|
+
tools:context=".MainActivity">
|
8
|
+
|
9
|
+
<Button
|
10
|
+
android:id="@+id/ExplicitButton"
|
11
|
+
android:layout_width="wrap_content"
|
12
|
+
android:layout_height="wrap_content"
|
13
|
+
android:layout_marginVertical="400dp"
|
14
|
+
android:layout_marginTop="88dp"
|
15
|
+
android:text="Explicit Intents"
|
16
|
+
android:textAllCaps="true"
|
17
|
+
app:layout_constraintEnd_toEndOf="parent"
|
18
|
+
app:layout_constraintHorizontal_bias="0.455"
|
19
|
+
app:layout_constraintStart_toStartOf="parent"
|
20
|
+
app:layout_constraintTop_toTopOf="parent" />
|
21
|
+
|
22
|
+
|
23
|
+
<Button
|
24
|
+
android:id="@+id/B1"
|
25
|
+
android:layout_width="wrap_content"
|
26
|
+
android:layout_height="wrap_content"
|
27
|
+
android:layout_marginTop="40dp"
|
28
|
+
android:layout_marginEnd="144dp"
|
29
|
+
android:text="Implicit Intents"
|
30
|
+
app:layout_constraintEnd_toEndOf="parent"
|
31
|
+
app:layout_constraintTop_toBottomOf="@+id/ExplicitButton" />
|
32
|
+
|
33
|
+
</android.support.constraint.ConstraintLayout>
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
3
|
+
xmlns:app="http://schemas.android.com/apk/res-auto"
|
4
|
+
xmlns:tools="http://schemas.android.com/tools"
|
5
|
+
android:layout_width="match_parent"
|
6
|
+
android:layout_height="match_parent"
|
7
|
+
tools:context=".secondactivity">
|
8
|
+
<TextView
|
9
|
+
android:id="@+id/resultTv"
|
10
|
+
android:textSize="30sp"
|
11
|
+
android:textStyle="bold"
|
12
|
+
android:text="helllo"
|
13
|
+
android:textColor="#000"
|
14
|
+
android:layout_width="match_parent"
|
15
|
+
android:layout_height="wrap_content" />
|
16
|
+
</LinearLayout>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
package com.example.implicit
|
2
|
+
import android.content.Intent
|
3
|
+
import android.support.v7.app.AppCompatActivity
|
4
|
+
import android.os.Bundle
|
5
|
+
import android.widget.Button
|
6
|
+
|
7
|
+
class secondactivity:AppCompatActivity() {
|
8
|
+
override fun onCreate(savedInstanceState: Bundle?) {
|
9
|
+
super.onCreate(savedInstanceState)
|
10
|
+
setContentView(R.layout.second)
|
11
|
+
|
12
|
+
//Explicit Intent
|
13
|
+
|
14
|
+
}
|
15
|
+
}
|
@@ -0,0 +1,60 @@
|
|
1
|
+
package com.example.animation
|
2
|
+
|
3
|
+
import android.support.v7.app.AppCompatActivity
|
4
|
+
import android.os.Bundle
|
5
|
+
import android.view.animation.AnimationUtils
|
6
|
+
import android.widget.Button
|
7
|
+
import android.widget.TextView
|
8
|
+
|
9
|
+
class MainActivity : AppCompatActivity() {
|
10
|
+
|
11
|
+
override fun onCreate(savedInstanceState: Bundle?) {
|
12
|
+
super.onCreate(savedInstanceState)
|
13
|
+
setContentView(R.layout.activity_main)
|
14
|
+
|
15
|
+
val textView = findViewById<TextView>(R.id.textView)
|
16
|
+
|
17
|
+
findViewById<Button>(R.id.fade_in).setOnClickListener {
|
18
|
+
val animation = AnimationUtils.loadAnimation(this, R.anim.fad_in)
|
19
|
+
textView.startAnimation(animation)
|
20
|
+
}
|
21
|
+
|
22
|
+
findViewById<Button>(R.id.fade_out).setOnClickListener {
|
23
|
+
val animation = AnimationUtils.loadAnimation(this, R.anim.fade_out)
|
24
|
+
textView.startAnimation(animation)
|
25
|
+
}
|
26
|
+
|
27
|
+
findViewById<Button>(R.id.zoom_in).setOnClickListener {
|
28
|
+
val animation = AnimationUtils.loadAnimation(this, R.anim.zoom_in)
|
29
|
+
textView.startAnimation(animation)
|
30
|
+
}
|
31
|
+
|
32
|
+
findViewById<Button>(R.id.zoom_out).setOnClickListener {
|
33
|
+
val animation = AnimationUtils.loadAnimation(this, R.anim.zoom_out)
|
34
|
+
textView.startAnimation(animation)
|
35
|
+
}
|
36
|
+
|
37
|
+
findViewById<Button>(R.id.slide_up).setOnClickListener {
|
38
|
+
val animation = AnimationUtils.loadAnimation(this, R.anim.slide_up)
|
39
|
+
textView.startAnimation(animation)
|
40
|
+
}
|
41
|
+
|
42
|
+
findViewById<Button>(R.id.slide_down).setOnClickListener {
|
43
|
+
val animation = AnimationUtils.loadAnimation(this, R.anim.slide_down)
|
44
|
+
textView.startAnimation(animation)
|
45
|
+
}
|
46
|
+
|
47
|
+
findViewById<Button>(R.id.bounce).setOnClickListener {
|
48
|
+
val animation = AnimationUtils.loadAnimation(this, R.anim.bounce)
|
49
|
+
textView.startAnimation(animation)
|
50
|
+
}
|
51
|
+
|
52
|
+
findViewById<Button>(R.id.rotate).setOnClickListener {
|
53
|
+
textView.animate().apply {
|
54
|
+
duration = 1000
|
55
|
+
rotationXBy(360f)
|
56
|
+
}.start()
|
57
|
+
}
|
58
|
+
}
|
59
|
+
}
|
60
|
+
|
@@ -0,0 +1,122 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
3
|
+
xmlns:app="http://schemas.android.com/apk/res-auto"
|
4
|
+
xmlns:tools="http://schemas.android.com/tools"
|
5
|
+
android:layout_width="match_parent"
|
6
|
+
android:layout_height="match_parent"
|
7
|
+
tools:context=".MainActivity">
|
8
|
+
|
9
|
+
<TextView
|
10
|
+
android:id="@+id/textView"
|
11
|
+
android:layout_width="match_parent"
|
12
|
+
android:layout_height="match_parent"
|
13
|
+
android:layout_above="@+id/linearLayout"
|
14
|
+
android:gravity="center"
|
15
|
+
android:text="Mobile Application Development"
|
16
|
+
android:textSize="32sp"
|
17
|
+
android:textColor="@color/teal_200"
|
18
|
+
android:textStyle="bold" />
|
19
|
+
|
20
|
+
<LinearLayout
|
21
|
+
android:id="@+id/linearLayout"
|
22
|
+
android:layout_width="match_parent"
|
23
|
+
android:layout_height="wrap_content"
|
24
|
+
android:layout_alignParentBottom="true"
|
25
|
+
android:orientation="vertical">
|
26
|
+
|
27
|
+
<LinearLayout
|
28
|
+
android:layout_width="match_parent"
|
29
|
+
android:layout_height="wrap_content"
|
30
|
+
android:orientation="horizontal"
|
31
|
+
android:weightSum="2">
|
32
|
+
|
33
|
+
<Button
|
34
|
+
android:id="@+id/fade_in"
|
35
|
+
android:layout_width="0dp"
|
36
|
+
android:layout_height="match_parent"
|
37
|
+
android:layout_weight="1"
|
38
|
+
android:text="Fade In"
|
39
|
+
android:textAllCaps="false" />
|
40
|
+
|
41
|
+
<Button
|
42
|
+
android:id="@+id/fade_out"
|
43
|
+
android:layout_width="0dp"
|
44
|
+
android:layout_height="match_parent"
|
45
|
+
android:layout_weight="1"
|
46
|
+
android:text="Fade Out"
|
47
|
+
android:textAllCaps="false" />
|
48
|
+
</LinearLayout>
|
49
|
+
|
50
|
+
<LinearLayout
|
51
|
+
android:layout_width="match_parent"
|
52
|
+
android:layout_height="wrap_content"
|
53
|
+
android:orientation="horizontal"
|
54
|
+
android:weightSum="2">
|
55
|
+
|
56
|
+
<Button
|
57
|
+
android:id="@+id/zoom_in"
|
58
|
+
android:layout_width="0dp"
|
59
|
+
android:layout_height="match_parent"
|
60
|
+
android:layout_weight="1"
|
61
|
+
android:text="Zoom In"
|
62
|
+
android:textAllCaps="false" />
|
63
|
+
|
64
|
+
<Button
|
65
|
+
android:id="@+id/zoom_out"
|
66
|
+
android:layout_width="0dp"
|
67
|
+
android:layout_height="match_parent"
|
68
|
+
android:layout_weight="1"
|
69
|
+
android:text="Zoom Out"
|
70
|
+
android:textAllCaps="false" />
|
71
|
+
</LinearLayout>
|
72
|
+
|
73
|
+
<LinearLayout
|
74
|
+
android:layout_width="match_parent"
|
75
|
+
android:layout_height="wrap_content"
|
76
|
+
android:orientation="horizontal"
|
77
|
+
android:weightSum="2">
|
78
|
+
|
79
|
+
<Button
|
80
|
+
android:id="@+id/slide_down"
|
81
|
+
android:layout_width="0dp"
|
82
|
+
android:layout_height="match_parent"
|
83
|
+
android:layout_weight="1"
|
84
|
+
android:text="Slide Down"
|
85
|
+
android:textAllCaps="false" />
|
86
|
+
|
87
|
+
<Button
|
88
|
+
android:id="@+id/slide_up"
|
89
|
+
android:layout_width="0dp"
|
90
|
+
android:layout_height="match_parent"
|
91
|
+
android:layout_weight="1"
|
92
|
+
android:text="Slide Up"
|
93
|
+
android:textAllCaps="false" />
|
94
|
+
</LinearLayout>
|
95
|
+
|
96
|
+
<LinearLayout
|
97
|
+
android:layout_width="match_parent"
|
98
|
+
android:layout_height="wrap_content"
|
99
|
+
android:orientation="horizontal"
|
100
|
+
android:weightSum="2">
|
101
|
+
|
102
|
+
<Button
|
103
|
+
android:id="@+id/bounce"
|
104
|
+
android:layout_width="0dp"
|
105
|
+
android:layout_height="match_parent"
|
106
|
+
android:layout_weight="1"
|
107
|
+
android:text="Bounce"
|
108
|
+
android:textAllCaps="false" />
|
109
|
+
|
110
|
+
<Button
|
111
|
+
android:id="@+id/rotate"
|
112
|
+
android:layout_width="0dp"
|
113
|
+
android:layout_height="match_parent"
|
114
|
+
android:layout_weight="1"
|
115
|
+
android:text="Rotate"
|
116
|
+
android:textAllCaps="false" />
|
117
|
+
</LinearLayout>
|
118
|
+
|
119
|
+
</LinearLayout>
|
120
|
+
|
121
|
+
|
122
|
+
</RelativeLayout>
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<set xmlns:android="http://schemas.android.com/apk/res/android">
|
3
|
+
<translate
|
4
|
+
android:fromYDelta="100%"
|
5
|
+
android:toYDelta="-20%"
|
6
|
+
android:duration="300" />
|
7
|
+
<translate
|
8
|
+
android:startOffset="500"
|
9
|
+
android:fromYDelta="-20%"
|
10
|
+
android:toYDelta="10%"
|
11
|
+
android:duration="150" />
|
12
|
+
<translate
|
13
|
+
android:startOffset="1000"
|
14
|
+
android:fromYDelta="10%"
|
15
|
+
android:toYDelta="0"
|
16
|
+
android:duration="100" />
|
17
|
+
</set>
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<set xmlns:android="http://schemas.android.com/apk/res/android">
|
3
|
+
<scale
|
4
|
+
android:duration="1000"
|
5
|
+
android:fromXScale="1"
|
6
|
+
android:fromYScale="1"
|
7
|
+
android:pivotX="50%"
|
8
|
+
android:pivotY="50%"
|
9
|
+
android:toXScale="1.5"
|
10
|
+
android:toYScale="1.5" />
|
11
|
+
</set>
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<set xmlns:android="http://schemas.android.com/apk/res/android">
|
3
|
+
<scale
|
4
|
+
android:duration="1000"
|
5
|
+
android:fromXScale="1.0"
|
6
|
+
android:fromYScale="1.0"
|
7
|
+
android:pivotX="50%"
|
8
|
+
android:pivotY="50%"
|
9
|
+
android:toXScale="0.5"
|
10
|
+
android:toYScale="0.5" />
|
11
|
+
</set>
|
@@ -0,0 +1,51 @@
|
|
1
|
+
package com.example.canvas
|
2
|
+
|
3
|
+
import android.graphics.Bitmap
|
4
|
+
import android.graphics.Canvas
|
5
|
+
import android.graphics.Color
|
6
|
+
import android.graphics.Paint
|
7
|
+
import android.graphics.drawable.BitmapDrawable
|
8
|
+
import android.graphics.drawable.ShapeDrawable
|
9
|
+
import android.graphics.drawable.shapes.OvalShape
|
10
|
+
import android.graphics.drawable.shapes.RectShape
|
11
|
+
import android.support.v7.app.AppCompatActivity
|
12
|
+
import android.os.Bundle
|
13
|
+
import android.widget.ImageView
|
14
|
+
|
15
|
+
class MainActivity : AppCompatActivity() {
|
16
|
+
override fun onCreate(savedInstanceState: Bundle?) {
|
17
|
+
super.onCreate(savedInstanceState)
|
18
|
+
setContentView(R.layout.activity_main)
|
19
|
+
val bitmap: Bitmap = Bitmap.createBitmap(700, 1000,
|
20
|
+
Bitmap.Config.ARGB_8888)
|
21
|
+
val canvas: Canvas = Canvas(bitmap)
|
22
|
+
var shapeDrawable: ShapeDrawable
|
23
|
+
// rectangle positions
|
24
|
+
var left = 100
|
25
|
+
var top = 100
|
26
|
+
var right = 600
|
27
|
+
var bottom = 400
|
28
|
+
|
29
|
+
// draw rectangle shape to canvas
|
30
|
+
shapeDrawable = ShapeDrawable(RectShape())
|
31
|
+
shapeDrawable.setBounds( left, top, right, bottom)
|
32
|
+
shapeDrawable.getPaint().setColor(Color.parseColor("#009944"))
|
33
|
+
shapeDrawable.draw(canvas)
|
34
|
+
// draw oval shape to canvas
|
35
|
+
shapeDrawable = ShapeDrawable(OvalShape())
|
36
|
+
shapeDrawable.setBounds( 100, 500, 600, 800)
|
37
|
+
shapeDrawable.getPaint().setColor(Color.parseColor("#009191"))
|
38
|
+
shapeDrawable.draw(canvas)
|
39
|
+
val iv = findViewById<ImageView>(R.id.imageV)
|
40
|
+
// now bitmap holds the updated pixels
|
41
|
+
// set bitmap as background to ImageView
|
42
|
+
|
43
|
+
val pCircle = Paint()
|
44
|
+
pCircle.setColor(Color.BLACK)
|
45
|
+
canvas.drawCircle(30f, 30f, 30f, pCircle)
|
46
|
+
val pBackground = Paint()
|
47
|
+
pBackground.color = Color.RED
|
48
|
+
canvas.drawRect(450f, 450f, 500f, 500f, pBackground)
|
49
|
+
iv.background = BitmapDrawable(getResources(), bitmap)
|
50
|
+
}
|
51
|
+
}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
3
|
+
xmlns:app="http://schemas.android.com/apk/res-auto"
|
4
|
+
xmlns:tools="http://schemas.android.com/tools"
|
5
|
+
android:layout_width="match_parent"
|
6
|
+
android:layout_height="match_parent"
|
7
|
+
tools:context=".MainActivity">
|
8
|
+
|
9
|
+
<ImageView
|
10
|
+
android:id="@+id/imageV"
|
11
|
+
android:layout_width="315dp"
|
12
|
+
android:layout_height="526dp"
|
13
|
+
android:layout_marginTop="100dp"
|
14
|
+
android:layout_marginEnd="50dp"
|
15
|
+
app:layout_constraintEnd_toEndOf="parent"
|
16
|
+
app:layout_constraintTop_toTopOf="parent" />
|
17
|
+
|
18
|
+
</android.support.constraint.ConstraintLayout>
|