import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.Card
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Surface
import androidx.compose.material.Text
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.layout.AlignmentLine
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.neco_desarrollo.composelessonsyt.ui.theme.ComposeLessonsYTTheme
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
Column() {
ListItem("Zac Efron", "Actor")
ListItem("Zac Efron", "Actor")
ListItem("Zac Efron", "Actor")
ListItem("Zac Efron", "Actor")
ListItem("Zac Efron", "Actor")
ListItem("Zac Efron", "Actor")
}
}
}
}
@Composable
private fun ListItem(name: String, prof: String){
Card(
modifier = Modifier
.fillMaxWidth()
.padding(10.dp),
shape = RoundedCornerShape(15.dp),
elevation = 5.dp
) {
Box(){
Row(
verticalAlignment = Alignment.CenterVertically
) {
Image(
painter = painterResource(id = R.drawable.image),
contentDescription = "image",
contentScale = ContentScale.Crop,
modifier = Modifier
.padding(5.dp)
.size(64.dp)
.clip(CircleShape)
)
Column(
modifier = Modifier.padding(start = 16.dp)
) {
Text(text = name)
Text(text = prof)
}
}
}
}
}
Ссылка на ролик не правильная стоит. Перебрасывает на урок № 3
Всем привет,
почему постоянно выдаёт ошибку вот в этом месте
Type mismatch: inferred type is Dp but CardElevation was expected
elevation = 5.dp
когда поменял на это то вроде заработало
elevation = CardDefaults.cardElevation(
defaultElevation = 5.dp
)
да есть такой трабл..
Да, ссылка не правильная
правильная ссылка на урок
https://www.youtube.com/watch?v=xbNScpVwlq4