0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

9. ホーム セクション - スロット API

  • 作成したLazyRow,LazyHorizontalGridを同一のページに表示する
    • 空のUI(slot)を提供するslotAPIを使用する
  • 作成したコンポーザブルの最後のパラメータにラムダを受け取るcontentを追加する
  • content引数に渡されるのが

最小構成

@Composable
fun HomeSection(
    @StringRes title: Int,
    modifier: Modifier = Modifier,
    content: @Composable () -> Unit
){
    Column(modifier){
        Text(stringResource(title)),
        content()
    }
}

//呼び出し時
 HomeSection(R.stirng.align_your_body){
     // ここで呼び出した関数が、contentに渡される
     AlignYourBodyRow()
 }

Text()の微調整

  • テキストのベースラインと上部の間の間隔は40.dp
    • modifier.paddingFromBaseLine(top = 40.dp)
  • ベースラインと要素の底部の間隔は16.dp
    • modifier.paddingFromBaseLine(bottom = 16.dp)
  • 水平方向のpaddingは16.dp
    • modifier.padding(horizontal = 16.dp)
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?