Anastasia Soboleva | 1de1d10 | 2019-09-30 16:48:31 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2019 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package androidx.ui.layout.samples |
| 18 | |
| 19 | import androidx.annotation.Sampled |
Anastasia Soboleva | 1de1d10 | 2019-09-30 16:48:31 +0100 | [diff] [blame] | 20 | import androidx.compose.Composable |
| 21 | import androidx.ui.core.dp |
| 22 | import androidx.ui.foundation.ColoredRect |
| 23 | import androidx.ui.graphics.Color |
Adam Powell | 712dc99 | 2019-12-04 12:48:30 -0800 | [diff] [blame^] | 24 | import androidx.ui.layout.LayoutAspectRatio |
Anastasia Soboleva | 1de1d10 | 2019-09-30 16:48:31 +0100 | [diff] [blame] | 25 | import androidx.ui.layout.Container |
| 26 | import androidx.ui.layout.DpConstraints |
| 27 | |
| 28 | @Sampled |
| 29 | @Composable |
| 30 | fun SimpleAspectRatio() { |
| 31 | Container(constraints = DpConstraints.tightConstraintsForWidth(100.dp)) { |
Adam Powell | 712dc99 | 2019-12-04 12:48:30 -0800 | [diff] [blame^] | 32 | ColoredRect(color = Color.Gray, modifier = LayoutAspectRatio(2f)) |
Anastasia Soboleva | 1de1d10 | 2019-09-30 16:48:31 +0100 | [diff] [blame] | 33 | } |
| 34 | } |