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?

android(kotlin):'This material API is experimental and is likely to change or to be removed in the future'エラーの解決

Posted at

解決方法

Optinアノテーションを用いる.

エラーメッセージについて

「This material API is experimental and is likely to change or to be removed in the future」:このマテリアルAPIは試験版で,将来的に変化する可能性や取り除かれる可能性がある.

例)アプリのトップアプリバーとして,テキストを中央配置したい.

MainActivity.kt
@Composable
fun TopAppBar(modifier: Modifier = Modifier) {
    CenterAlignedTopAppBar(
        title = {
            Text(
                text = stringResource(R.string.app_name)
            )
        },
        modifier = modifier
    ))
}

{C63FD006-2B03-403F-A64A-96C5D18F2FF0}.png

MainAcitivy.kt
@OptIn(ExperimentalMaterial3API::class)
@Composable
fun TopAppBar(modifier: Modifier = Modifier) {
    CenterAlignedTopAppBar(
        title = {
            Text(
                text = stringResource(R.string.app_name)
            )
        },
        modifier = modifier
    )
}

@OptIn

The Kotlin standard library provides a mechanism for requiring and giving explicit consent to use certain API elements. This mechanism allows library authors to inform users about specific conditions that require opt-in, such as when an API is in an experimental state and is likely to change in the future.

「Kotlin標準ライブラリは、特定のAPI要素を使用するために、明示的な同意を要求し、与えるためのメカニズムを提供する。このメカニズムにより、ライブラリの作者は、APIが実験的な状態にあり、将来的に変更される可能性がある場合など、オプトインを必要とする特定の条件についてユーザーに通知することができます。」という意味から、@Optinアノテーションを用いることで、将来的に変更が生じるAPIを使用することができるという認識である。

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?