google-developer-training / basic-android-kotlin-compose-training-woof

Apache License 2.0
56 stars 87 forks source link

Material Theming: Android Basics with Compose #45

Closed SHPILEVAYAEVGENIYA closed 1 year ago

SHPILEVAYAEVGENIYA commented 1 year ago

URL of codelab https://developer.android.com/codelabs/basic-android-kotlin-compose-material-theming?continue=https%3A%2F%2Fdeveloper.android.com%2Fcourses%2Fpathways%2Fandroid-basics-compose-unit-3-pathway-3%23codelab-https%3A%2F%2Fdeveloper.android.com%2Fcodelabs%2Fbasic-android-kotlin-compose-material-theming#4

In which task and step of the codelab can this issue be found?

  1. Add shape

Describe the problem For change shape of icon dogs (to round corner) I must do some steps (in attach file). But I don't understand this line:
.clip(MaterialTheme.shapes.small),

If I understand correctly I add this lines val Shapes = Shapes( small = RoundedCornerShape(50.dp), ) to add this: .clip(Shapes.small)

am I right?

Steps to reproduce?

  1. Go to...
  2. Click on...
  3. See error...

Versions Android Studio version: API version of the emulator:

Additional information Include screenshots if they would be useful in clarifying the problem.

johnshea commented 1 year ago

Hi @SHPILEVAYAEVGENIYA

Thank you for writing in with your question.

To get the images to be rounded and not square/rectangular...

You need to make the changes to the Shape.kt file as described in the lesson.

You then use this by calling .clip(MaterialTheme.shapes.small). This will round your images based on the value in the Shape.kt file.

You add the actual value in the Shape.kt file so that is can be used throughout your program and not by setting the value each time.

If you ever need to change the shape size, only the value in the Shape.kt file needs to change.

Hope you enjoying the course!

Regards.