Skip to content

Instantly share code, notes, and snippets.

@tewha
Created March 26, 2022 23:46
Show Gist options
  • Save tewha/183fc3ceba917615955af96b5b8833d4 to your computer and use it in GitHub Desktop.
Save tewha/183fc3ceba917615955af96b5b8833d4 to your computer and use it in GitHub Desktop.
Three column row
package com.example.myapplication
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.layout.*
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Surface
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.example.myapplication.ui.theme.MyApplicationTheme
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
MyApplicationTheme {
// A surface container using the 'background' color from the theme
Surface(
modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colors.background
) {
SampleRow()
}
}
}
}
}
@Composable
fun SampleRow() {
Row(
horizontalArrangement = Arrangement.spacedBy(8.dp),
modifier = Modifier.fillMaxWidth()
)
{
Text("Left1")
Text("Left2")
Spacer(Modifier.weight(1f))
Text("Right")
}
}
@Preview(showBackground = true)
@Composable
fun DefaultPreview() {
MyApplicationTheme {
SampleRow()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment