경우에 따라 XML과 RemoteViews를 사용하여 뷰를 제공할 수 있습니다.
이미 Glance를 사용하지 않고 기능을 구현했거나 기능이
현재 Glance API에서 아직 사용할 수 없거나 사용할 수 없습니다. 이러한 상황에서는
Glance는 상호 운용성 API인 AndroidRemoteViews를 제공합니다.
AndroidRemoteViews 컴포저블을 사용하면 RemoteViews를 함께 배치할 수 있습니다.
다음과 같습니다.
valpackageName=LocalContext.current.packageNameColumn(modifier=GlanceModifier.fillMaxSize()){Text("Isn't that cool?")AndroidRemoteViews(RemoteViews(packageName,R.layout.example_layout))}
Glance를 사용하지 않는 것처럼 RemoteViews를 만들고 정의한 후 전달하면 됩니다.
매개변수로 전달하세요.
또한 컴포저블의 RemoteViews 컨테이너를 만들 수 있습니다.
AndroidRemoteViews(remoteViews=RemoteViews(packageName,R.layout.my_container_view),containerViewId=R.id.example_view){Column(modifier=GlanceModifier.fillMaxSize()){Text("My title")Text("Maybe a long content...")}}
이 페이지에 나와 있는 콘텐츠와 코드 샘플에는 콘텐츠 라이선스에서 설명하는 라이선스가 적용됩니다. 자바 및 OpenJDK는 Oracle 및 Oracle 계열사의 상표 또는 등록 상표입니다.
최종 업데이트: 2025-08-27(UTC)
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["필요한 정보가 없음","missingTheInformationINeed","thumb-down"],["너무 복잡함/단계 수가 너무 많음","tooComplicatedTooManySteps","thumb-down"],["오래됨","outOfDate","thumb-down"],["번역 문제","translationIssue","thumb-down"],["샘플/코드 문제","samplesCodeIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-08-27(UTC)"],[],[],null,["In some cases, you may want to use XML and `RemoteViews` to provide a view.\nPerhaps you have already implemented a feature without Glance, or the feature is\nnot yet available or possible with the current Glance API. For these situations,\nGlance provides `AndroidRemoteViews`, an interoperability API.\n\nThe `AndroidRemoteViews` composable allows `RemoteViews` to be placed together\nwith your other composables:\n\n\n```kotlin\nval packageName = LocalContext.current.packageName\nColumn(modifier = GlanceModifier.fillMaxSize()) {\n Text(\"Isn't that cool?\")\n AndroidRemoteViews(RemoteViews(packageName, R.layout.example_layout))\n}https://github.com/android/snippets/blob/5673ffc60b614daf028ee936227128eb8c4f9781/compose/snippets/src/main/java/com/example/compose/snippets/glance/GlanceSnippets.kt#L903-L907\n```\n\n\u003cbr /\u003e\n\nCreate and define the `RemoteViews` as you would without Glance, and simply pass\nit as a parameter.\n\nIn addition, you can create `RemoteViews` containers for your composables:\n\n\n```kotlin\nAndroidRemoteViews(\n remoteViews = RemoteViews(packageName, R.layout.my_container_view),\n containerViewId = R.id.example_view\n) {\n Column(modifier = GlanceModifier.fillMaxSize()) {\n Text(\"My title\")\n Text(\"Maybe a long content...\")\n }\n}https://github.com/android/snippets/blob/5673ffc60b614daf028ee936227128eb8c4f9781/compose/snippets/src/main/java/com/example/compose/snippets/glance/GlanceSnippets.kt#L916-L925\n```\n\n\u003cbr /\u003e\n\nIn this case, a layout that contains the \"container\" is passed with the defined\nID. This container must be a [`ViewGroup`](/reference/android/view/ViewGroup), since it is used to place the\ndefined content.\n| **Note:** Any children of the defined container are removed and replaced with the content. Also, the provided `ViewGroup` must be supported by `RemoteViews.` See [`RemoteViewsWidget.kt`](https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:glance/glance-appwidget/integration-tests/demos/src/main/java/androidx/glance/appwidget/demos/RemoteViewsWidget.kt) for an example of using `AndroidRemoteViews`."]]