Skip to content

Commit

Permalink
Added Customo paint View
Browse files Browse the repository at this point in the history
  • Loading branch information
hi-manshu committed Oct 4, 2020
1 parent 84a6e15 commit 8565d3f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/src/main/java/com/gappein/sample/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class MainActivity : AppCompatActivity() {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)

val x = Generator(this).setText(TextValues(text = "Himanshu")).draw()
val x = Generator(this).setText(TextValues(text = "hey Himanshuhey Himan")).draw()
background.setImageBitmap(x)
}
}
4 changes: 2 additions & 2 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
tools:context=".MainActivity">

<ImageView
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
android:id="@+id/background"
app:layout_constraintBottom_toBottomOf="parent"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ data class DrawingValues(
paint.setTypeface(ResourcesCompat.getFont(context, R.font.bumper))
paint.color = Color.BLACK
paint.style = Paint.Style.FILL
paint.textSize = 20F
paint.textSize = 52F
paint.getTextBounds(text.text, 0, text.text.length, this)
}
}
Expand All @@ -59,14 +59,18 @@ data class DrawingValues(

companion object {

private val paint = Paint(Paint.ANTI_ALIAS_FLAG)
private val paint = Paint(Paint.ANTI_ALIAS_FLAG).apply {
style = Paint.Style.FILL_AND_STROKE
strokeWidth = 10F
color = Color.BLACK
}

fun default(context: Context) = DrawingValues(
context = context,
paint = paint,
text = TextValues(""),
isMultiline = false,
bitmap = Bitmap.createBitmap(200, 200, Bitmap.Config.ARGB_8888)
bitmap = Bitmap.createBitmap(400, 300, Bitmap.Config.ARGB_8888)
)
}
}

0 comments on commit 8565d3f

Please sign in to comment.