Wear OS에서 목록 만들기
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
Compose 사용해 보기
Wear OS용 Jetpack Compose는 Wear OS에 권장되는 UI 도구 키트입니다.
목록이 있으면 사용자는 Wear OS 기기에서 여러 선택 항목 중 하나를 쉽게 고를 수 있습니다.
웨어러블 UI 라이브러리에는 WearableRecyclerView
클래스가 포함되어 있으며 이 클래스는 웨어러블 기기에 최적화된 목록을 만들기 위한 RecyclerView
구현입니다. 새로운 WearableRecyclerView
컨테이너를 만들어 웨어러블 앱에서 이 인터페이스를 사용할 수 있습니다.
애플리케이션 런처 또는 연락처 목록과 같은 간단한 항목의 긴 목록에는 WearableRecyclerView
를 사용하세요. 각 항목에는 짧은 문자열 및 관련 아이콘이 있을 수 있습니다. 또는 각 항목에 문자열과 아이콘 중 하나만 있을 수도 있습니다.
참고: 복잡한 레이아웃은 사용하지 마세요. 사용자는 특히 웨어러블 기기의 제한된 화면 크기에서는 항목을 한번 보고 어떤 내용인지 파악할 수 있어야 합니다.
WearableRecyclerView
API는 기본적으로 기존의 RecyclerView
클래스를 확장하여 세로로 스크롤 가능한 항목 목록을 일자형 목록으로 표시합니다. WearableRecyclerView
API를 사용하면 웨어러블 앱에서 곡선 레이아웃 및 원형 스크롤 동작을 선택할 수 있습니다.
그림 1.
Wear OS의 기본 목록 보기
이 가이드에서는 WearableRecyclerView
클래스를 사용하여 Wear OS 앱에서 목록을 만드는 방법과 스크롤 가능한 항목을 위한 곡선형 레이아웃을 선택하는 방법, 스크롤하는 동안 하위 요소의 모양을 맞춤설정하는 방법을 보여줍니다.
XML을 사용하여 활동에 WearableRecyclerView 추가
다음 레이아웃은 활동에 WearableRecyclerView
를 추가합니다.
<androidx.wear.widget.WearableRecyclerView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/recycler_launcher_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical" />
다음 예는 활동에 적용된 WearableRecyclerView
를 보여줍니다.
Kotlin
class MainActivity : Activity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
}
...
}
Java
public class MainActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
...
}
곡선형 레이아웃 만들기
웨어러블 앱에서 스크롤 가능한 항목의 곡선형 레이아웃을 만들려면 다음을 실행하세요.
Kotlin
wearableRecyclerView.apply {
// To align the edge children (first and last) with the center of the screen.
isEdgeItemsCenteringEnabled = true
...
layoutManager = WearableLinearLayoutManager(this@MainActivity)
}
자바
// To align the edge children (first and last) with the center of the screen.
wearableRecyclerView.setEdgeItemsCenteringEnabled(true);
...
wearableRecyclerView.setLayoutManager(
new WearableLinearLayoutManager(this));
항목이 중앙에서 멀리 스크롤될 때 아이콘과 텍스트의 크기를 조절해야 하는 등 스크롤하는 동안 하위 요소의 모양을 맞춤설정해야 하는 특정 요구사항이 있는 앱의 경우
WearableLinearLayoutManager.LayoutCallback
클래스를 확장하고
onLayoutFinished
메서드를 재정의합니다.
다음 코드 스니펫은 WearableLinearLayoutManager.LayoutCallback
클래스를 확장하여 중앙에서 멀어질 때 크기가 조절되도록 항목의 스크롤을 맞춤설정하는 예를 보여줍니다.
Kotlin
/** How much icons should scale, at most. */
private const val MAX_ICON_PROGRESS = 0.65f
class CustomScrollingLayoutCallback : WearableLinearLayoutManager.LayoutCallback() {
private var progressToCenter: Float = 0f
override fun onLayoutFinished(child: View, parent: RecyclerView) {
child.apply {
// Figure out % progress from top to bottom.
val centerOffset = height.toFloat() / 2.0f / parent.height.toFloat()
val yRelativeToCenterOffset = y / parent.height + centerOffset
// Normalize for center.
progressToCenter = Math.abs(0.5f - yRelativeToCenterOffset)
// Adjust to the maximum scale.
progressToCenter = Math.min(progressToCenter, MAX_ICON_PROGRESS)
scaleX = 1 - progressToCenter
scaleY = 1 - progressToCenter
}
}
}
Java
public class CustomScrollingLayoutCallback extends WearableLinearLayoutManager.LayoutCallback {
/** How much icons should scale, at most. */
private static final float MAX_ICON_PROGRESS = 0.65f;
private float progressToCenter;
@Override
public void onLayoutFinished(View child, RecyclerView parent) {
// Figure out % progress from top to bottom.
float centerOffset = ((float) child.getHeight() / 2.0f) / (float) parent.getHeight();
float yRelativeToCenterOffset = (child.getY() / parent.getHeight()) + centerOffset;
// Normalize for center.
progressToCenter = Math.abs(0.5f - yRelativeToCenterOffset);
// Adjust to the maximum scale.
progressToCenter = Math.min(progressToCenter, MAX_ICON_PROGRESS);
child.setScaleX(1 - progressToCenter);
child.setScaleY(1 - progressToCenter);
}
}
Kotlin
wearableRecyclerView.layoutManager =
WearableLinearLayoutManager(this, CustomScrollingLayoutCallback())
Java
CustomScrollingLayoutCallback customScrollingLayoutCallback =
new CustomScrollingLayoutCallback();
wearableRecyclerView.setLayoutManager(
new WearableLinearLayoutManager(this, customScrollingLayoutCallback));
이 페이지에 나와 있는 콘텐츠와 코드 샘플에는 콘텐츠 라이선스에서 설명하는 라이선스가 적용됩니다. 자바 및 OpenJDK는 Oracle 및 Oracle 계열사의 상표 또는 등록 상표입니다.
최종 업데이트: 2025-07-26(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-07-26(UTC)"],[],[],null,["# Create lists on Wear OS\n\nTry the Compose way \nJetpack Compose on Wear OS is the recommended UI toolkit for Wear OS. \n[Create lists using Compose on Wear OS →](/training/wearables/compose/lists) \n\n\nLists let users select an item from a set of choices easily on Wear OS devices.\n\n\nThe Wearable UI Library includes the\n[`WearableRecyclerView`](/reference/androidx/wear/widget/WearableRecyclerView) class, which is a\n[`RecyclerView`](/reference/androidx/recyclerview/widget/RecyclerView)\nimplementation for creating lists optimized for wearable devices. You can use this\ninterface in your wearable app by creating a new `WearableRecyclerView` container.\n\n\nUse a `WearableRecyclerView` for a\nlong list of simple items, such as an application launcher or a list of contacts. Each item might\nhave a short string and an associated icon. Alternatively, each item might have only a string\nor an icon.\n\n\n**Note:** Avoid complex layouts. Users should only need to glance at an item to\nunderstand what it is, especially with wearables' limited screen size.\n\n\nBy extending the existing `RecyclerView` class, `WearableRecyclerView`\nAPIs display a vertically scrollable list of items in a straight list by default. You can also use\nthe `WearableRecyclerView` APIs to opt-in for a curved layout and\na [circular scrolling gesture](/reference/androidx/wear/widget/WearableRecyclerView#setCircularScrollingGestureEnabled(boolean))\nin your wearable apps.\n\n**Figure 1.**\nDefault list view on Wear OS.\n\n\nThis guide shows you how to use the `WearableRecyclerView` class to create\nlists in your Wear OS apps, how to opt-in for a curved layout\nfor your scrollable items, and how to customize the appearance of\nthe children while scrolling.\n\nAdd WearableRecyclerView to an activity using XML\n-------------------------------------------------\n\n\nThe following layout adds a `WearableRecyclerView` to an activity: \n\n```xml\n\u003candroidx.wear.widget.WearableRecyclerView\n xmlns:android=\"http://schemas.android.com/apk/res/android\"\n xmlns:tools=\"http://schemas.android.com/tools\"\n android:id=\"@+id/recycler_launcher_view\"\n android:layout_width=\"match_parent\"\n android:layout_height=\"match_parent\"\n android:scrollbars=\"vertical\" /\u003e\n```\n\n\nThe following example shows the `WearableRecyclerView`\napplied to an activity: \n\n### Kotlin\n\n```kotlin\nclass MainActivity : Activity() {\n\n override fun onCreate(savedInstanceState: Bundle?) {\n super.onCreate(savedInstanceState)\n setContentView(R.layout.activity_main)\n }\n ...\n}\n```\n\n### Java\n\n```java\npublic class MainActivity extends Activity {\n @Override\n public void onCreate(Bundle savedInstanceState) {\n super.onCreate(savedInstanceState);\n setContentView(R.layout.activity_main);\n }\n ...\n}\n```\n\nCreate a curved layout\n----------------------\n\n\nTo create a curved layout for scrollable items in your wearable app, do the following:\n\n- Use [`WearableRecyclerView`](/reference/androidx/wear/widget/WearableRecyclerView) as your main container in the relevant XML layout.\n- Set the [`setEdgeItemsCenteringEnabled(boolean)`](/reference/androidx/wear/widget/WearableRecyclerView#setEdgeItemsCenteringEnabled(boolean)) method to `true`. This vertically centers the first and last items on the list on the screen.\n- Use the `WearableRecyclerView.setLayoutManager()` method to set the layout of the items on the screen.\n\n### Kotlin\n\n```kotlin\nwearableRecyclerView.apply {\n // To align the edge children (first and last) with the center of the screen.\n isEdgeItemsCenteringEnabled = true\n ...\n layoutManager = WearableLinearLayoutManager(this@MainActivity)\n}\n```\n\n### Java\n\n```java\n// To align the edge children (first and last) with the center of the screen.\nwearableRecyclerView.setEdgeItemsCenteringEnabled(true);\n...\nwearableRecyclerView.setLayoutManager(\n new WearableLinearLayoutManager(this));\n```\n\n\nIf your app has specific requirements to customize the appearance of the children while scrolling---for example,\nscaling the icons and text while the items scroll away from the center---extend\nthe [`WearableLinearLayoutManager.LayoutCallback`](/reference/androidx/wear/widget/WearableLinearLayoutManager.LayoutCallback) class and override the\n[`onLayoutFinished`](/reference/androidx/wear/widget/WearableLinearLayoutManager.LayoutCallback#onLayoutFinished(android.view.View, androidx.recyclerview.widget.RecyclerView)) method.\n\n\nThe following code snippets show an example of customizing the scrolling of items to scale\nfarther away from the center by extending the\n`WearableLinearLayoutManager.LayoutCallback` class: \n\n### Kotlin\n\n```kotlin\n/** How much icons should scale, at most. */\nprivate const val MAX_ICON_PROGRESS = 0.65f\n\nclass CustomScrollingLayoutCallback : WearableLinearLayoutManager.LayoutCallback() {\n\n private var progressToCenter: Float = 0f\n\n override fun onLayoutFinished(child: View, parent: RecyclerView) {\n child.apply {\n // Figure out % progress from top to bottom.\n val centerOffset = height.toFloat() / 2.0f / parent.height.toFloat()\n val yRelativeToCenterOffset = y / parent.height + centerOffset\n\n // Normalize for center.\n progressToCenter = Math.abs(0.5f - yRelativeToCenterOffset)\n // Adjust to the maximum scale.\n progressToCenter = Math.min(progressToCenter, MAX_ICON_PROGRESS)\n\n scaleX = 1 - progressToCenter\n scaleY = 1 - progressToCenter\n }\n }\n}\n```\n\n### Java\n\n```java\npublic class CustomScrollingLayoutCallback extends WearableLinearLayoutManager.LayoutCallback {\n /** How much icons should scale, at most. */\n private static final float MAX_ICON_PROGRESS = 0.65f;\n\n private float progressToCenter;\n\n @Override\n public void onLayoutFinished(View child, RecyclerView parent) {\n\n // Figure out % progress from top to bottom.\n float centerOffset = ((float) child.getHeight() / 2.0f) / (float) parent.getHeight();\n float yRelativeToCenterOffset = (child.getY() / parent.getHeight()) + centerOffset;\n\n // Normalize for center.\n progressToCenter = Math.abs(0.5f - yRelativeToCenterOffset);\n // Adjust to the maximum scale.\n progressToCenter = Math.min(progressToCenter, MAX_ICON_PROGRESS);\n\n child.setScaleX(1 - progressToCenter);\n child.setScaleY(1 - progressToCenter);\n }\n}\n``` \n\n### Kotlin\n\n```kotlin\nwearableRecyclerView.layoutManager =\n WearableLinearLayoutManager(this, CustomScrollingLayoutCallback())\n```\n\n### Java\n\n```java\nCustomScrollingLayoutCallback customScrollingLayoutCallback =\n new CustomScrollingLayoutCallback();\nwearableRecyclerView.setLayoutManager(\n new WearableLinearLayoutManager(this, customScrollingLayoutCallback));\n```"]]