Development/Android

[Android] Widget에서 View 컴포넌트 사용 불가능 / Widget에서 사용 가능한 컴포넌트 종류

SeungYong.Lee 2025. 5. 8. 14:00
반응형

- xml RemoteViews 방식의 위젯 구성 중에 <View> 컴포넌트를 통해 구분선을 만들려고 하는데, 빌드하고 나니 '위젯을 표시할 수 없습니다'라는 오류가 발생했다.

 

- 이것은 같은 ViewGroup 계층이어도 RemoteViews에서 지원 가능한 View 종류가 한정되어 있기 때문이다.

 

A class that describes a view hierarchy that can be displayed in another process. The hierarchy is inflated from a layout resource file, and this class provides some basic operations for modifying the content of the inflated hierarchy.

RemoteViews is limited to support for the following layouts:

And the following widgets:

As of API 31, the following widgets and layouts may also be used:

Descendants of these classes are not supported.

 

- View 는 없는 것을 볼 수 있다. 대신 LinearLayout을 얇게 구성하여 background를 선언하면 View 대신 활용 가능하다.

 

- 아래처럼 구성하여 해결했다. 항상 작업 전에 지원 가능한 컴포넌트를 확인해 보자

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="1dp"
    android:background="@color/color_system_label_subtler_light" />
반응형