[go: nahoru, domu]

blob: db5d401e74ac50b15ef58f3ee53d592a3e585e77 [file] [log] [blame]
Mihai Popaf4b60202019-07-05 18:53:39 +01001/*
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
Louis Pullen-Freilich623e4052020-07-19 20:24:03 +010017package androidx.compose.foundation.layout.samples
Mihai Popaf4b60202019-07-05 18:53:39 +010018
19import androidx.annotation.Sampled
20import androidx.compose.Composable
Adam Powell999a89b2020-03-11 09:08:07 -070021import androidx.ui.core.Alignment
22import androidx.ui.core.Modifier
Louis Pullen-Freilichddda7be2020-07-17 18:28:12 +010023import androidx.compose.foundation.Box
Louis Pullen-Freilich4dc4dac2020-07-22 14:39:14 +010024import androidx.compose.ui.graphics.Color
Louis Pullen-Freilich623e4052020-07-19 20:24:03 +010025import androidx.compose.foundation.layout.Stack
26import androidx.compose.foundation.layout.fillMaxSize
27import androidx.compose.foundation.layout.padding
28import androidx.compose.foundation.layout.preferredSize
George Mount842c8c12020-01-08 16:03:42 -080029import androidx.ui.unit.dp
Mihai Popaf4b60202019-07-05 18:53:39 +010030
31@Sampled
32@Composable
33fun SimpleStack() {
34 Stack {
Adam Powell999a89b2020-03-11 09:08:07 -070035 Box(Modifier.fillMaxSize(), backgroundColor = Color.Cyan)
Matvei Malkov59bac362020-02-13 20:23:13 +000036 Box(
Adam Powell1899fa92020-04-02 11:05:15 -070037 Modifier.matchParentSize().padding(top = 20.dp, bottom = 20.dp),
Matvei Malkov59bac362020-02-13 20:23:13 +000038 backgroundColor = Color.Yellow
Anastasia Sobolevad7779a22019-11-21 16:34:26 +000039 )
Adam Powell1899fa92020-04-02 11:05:15 -070040 Box(Modifier.matchParentSize().padding(40.dp), backgroundColor = Color.Magenta)
Matvei Malkov59bac362020-02-13 20:23:13 +000041 Box(
Adam Powell999a89b2020-03-11 09:08:07 -070042 Modifier.gravity(Alignment.Center).preferredSize(300.dp, 300.dp),
43 backgroundColor = Color.Green
44 )
45 Box(
46 Modifier.gravity(Alignment.TopStart).preferredSize(150.dp, 150.dp),
47 backgroundColor = Color.Red
48 )
49 Box(
50 Modifier.gravity(Alignment.BottomEnd).preferredSize(150.dp, 150.dp),
Matvei Malkov59bac362020-02-13 20:23:13 +000051 backgroundColor = Color.Blue
Anastasia Sobolevad7779a22019-11-21 16:34:26 +000052 )
Mihai Popaf4b60202019-07-05 18:53:39 +010053 }
54}