Skip to main content

Posts

Showing posts with the label Shape

jetpack compose - Cut corner shape example

MainActivity.kt package com.cfsuman.jetpackcompose import androidx.appcompat.app.AppCompatActivity import android.os.Bundle import androidx.activity.compose.setContent import androidx.compose.foundation.background import androidx.compose.foundation.layout.* import androidx.compose.foundation.shape.CutCornerShape import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip import androidx.compose.ui.graphics.Color import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContent { MainContent() } } @Composable fun MainContent(){ val cutCornerShape = CutCornerShape(12.dp) val cutCornerShapeTopStart = CutCornerShape(topStart = 16.dp) Column( ...

jetpack compose - Circle shape example

MainActivity.kt package com.cfsuman.jetpackcompose import androidx.appcompat.app.AppCompatActivity import android.os.Bundle import androidx.activity.compose.setContent import androidx.compose.foundation.background import androidx.compose.foundation.layout.* import androidx.compose.foundation.shape.CircleShape import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip import androidx.compose.ui.graphics.Color import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContent { MainContent() } } @Composable fun MainContent(){ val circleShape = CircleShape Box( modifier = Modifier .fillMaxSize() .background(Color(0...

jetpack compose - Rounded corner shape example

Compose Rounded Corner Shape Jetpack Compose is an Android development modern toolkit that is used for building native android applications in a declarative syntax. In a Compose application, android developers need to write less code than the old XML-based layout coding style. In this android application development tutorial, we will demonstrate how we can create a rounded corner shape and apply it to a widget. We can create rounded corners for all sides of a widget or any specific side of a widget. Such as in a Box widget we can make 24 dp rounded corners for all of its sides. We can make rounded it top end side only. Even we can make rounded corner top start and bottom end sides only. We can apply a widget’s specific corner to a specific amount of rounded such as top end corner 12 dp and top start corner 8 dp. This we can easily implement inside a jetpack compose application. Now let us describe the coding we wrote in this tutorial to make a rounded corners widget. In our com...

jetpack compose - RectangleShape example

MainActivity.kt package com.cfsuman.jetpackcompose import androidx.appcompat.app.AppCompatActivity import android.os.Bundle import androidx.activity.compose.setContent import androidx.compose.foundation.background import androidx.compose.foundation.layout.* import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.RectangleShape import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContent { MainContent() } } @Composable fun MainContent(){ val rectangleShape = RectangleShape Box( modifier = Modifier .fillMaxSize() .background(Col...