Skip to content

Instantly share code, notes, and snippets.

View alohaabhi's full-sized avatar

Abhishek Jangra alohaabhi

View GitHub Profile
Text(
text = "Hello",
modifier = Modifier
.padding(16.dp)
.background(Color.LightGray)
.clip(CircleShape)
)
Text(
text = "Hello",
modifier = Modifier
.clip(CircleShape)
.background(Color.LightGray)
.padding(16.dp)
)
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/light_gray"/>
<corners android:radius="16dp" />
</shape>
val animatedCircleScale by animateFloatAsState(
targetValue = circleScale,
animationSpec = spring(Spring.DampingRatioHighBouncy)
)
var circleScale by remember { mutableStateOf(1f) }
val animatedCircleScale by animateFloatAsState(targetValue = circleScale)
Box(
modifier = Modifier
.scale(animatedCircleScale)
.requiredSize(100.dp)
.clip(CircleShape)
.background(MaterialTheme.colorScheme.primaryContainer)
)
Button(onClick = {
var circleScale by remember { mutableStateOf(1f) }
Box(
modifier = Modifier
.scale(circleScale)
.requiredSize(100.dp)
.clip(CircleShape)
.background(MaterialTheme.colorScheme.primaryContainer)
)
Button(onClick = {
circleScale = 0.5f
var count by remember { mutableStateOf(1) }
Text(text = "The count is $count.")
Button(onClick = {
count = count.inc()
}) {
Text(text = "Hit")
}
var count = 1
Text(text = "The count is $count.")
Button(onClick = {
count = count.inc()
}) {
Text(text = "Hit")
}
var count = 1
findViewById<Button>(R.id.incrementButton).setOnClickListener {
count = count.inc()
findViewById<TextView>(R.id.counterText).text = "The count is $count"
}
<TextView
android:id="@+id/counterText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:text="The count is 100"/>
<Button
android:id="@+id/incrementButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"