0

I've made a Raspberry Pi 3 run my application on Android Things, but a lot of graphic elements are not properly displayed. I've a RecyclerView with a list of items whose layout include a CardView. The CardView is not correctly displayed, and it's replaced by a simple rectangle.

On ordinary Android devices everything works.

That is really strange, because Android Things is based on Android 7.0. Has anyone been able to display everything properly?

This is my item layout:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@color/transparent">

    <android.support.v7.widget.CardView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="4dp"
        android:layout_marginLeft="6dp"
        android:layout_marginRight="6dp"
        android:layout_marginTop="4dp"
        android:background="@color/transparent"
        app:cardBackgroundColor="@color/background_list"
        app:cardCornerRadius="10dp">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@color/background_list"
            android:orientation="vertical">

            <FrameLayout
                android:id="@+id/framelayout"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="@color/white">

                <ImageView
                    android:id="@+id/image"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:scaleType="centerCrop" />

                <LinearLayout
                    android:id="@+id/text_content"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="horizontal"
                    android:padding="@dimen/text_margin">

                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:orientation="vertical">

                        <LinearLayout
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:orientation="horizontal">

                            <ImageButton
                                android:id="@+id/more_actions"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_gravity="left|center"
                                android:layout_marginRight="5dp"
                                android:layout_weight="0"
                                android:background="@color/ap_transparent"
                                android:tint="@color/soft_grey"
                                android:visibility="visible"
                                app:srcCompat="@drawable/ic_more_vert_black_24dp" />

                            <TextView
                                android:id="@+id/name"
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:layout_gravity="left|center"
                                android:layout_marginRight="@dimen/text_margin"
                                android:layout_weight="1"
                                android:fontFamily="sans-serif-medium"
                                android:text="Test"
                                android:textAppearance="@style/TextAppearance.AppCompat.Widget.ActionBar.Title" />
                        </LinearLayout>

                        <TextView
                            android:id="@+id/detail"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginRight="@dimen/text_margin"
                            android:layout_marginTop="5dp"
                            android:fontFamily="sans-serif"
                            android:text="Description test Description test Description test Description test Description test"
                            android:textAppearance="?attr/textAppearanceListItem"
                            android:textColor="@color/grey"
                            android:textSize="14sp"
                            android:visibility="visible" />

                        <TextView
                            android:id="@+id/last_sync"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginRight="@dimen/text_margin"
                            android:layout_marginTop="8dp"
                            android:fontFamily="sans-serif"
                            android:text="Last sync"
                            android:textAppearance="?android:attr/textAppearanceSmall"
                            android:textStyle="italic"
                            android:visibility="visible" />
                    </LinearLayout>

                    <TextView
                        android:id="@+id/main_sensor_value"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center"
                        android:layout_weight="0"
                        android:text="25°C"
                        android:textAppearance="?android:attr/textAppearanceMedium"
                        android:textSize="20sp"
                        android:visibility="visible" />
                </LinearLayout>

            </FrameLayout>

        </LinearLayout>

    </android.support.v7.widget.CardView>


</FrameLayout>
RiccardoCh
  • 1,060
  • 1
  • 13
  • 24
  • any screenshots? or code to reproduce? https://stackoverflow.com/help/mcve – Blundell Jun 28 '17 at 08:39
  • @Blundell to reproduce this issue you need Android Things installed on Raspberry Pi and a layout with a CardView – RiccardoCh Jun 28 '17 at 08:44
  • 1
    Your layout does not have a `CardView`. – CommonsWare Jun 28 '17 at 10:59
  • @CommonsWare sorry, I've added the wrong layout. Anyway, like I wrote, in Android Things CardiView is not correctly displayed – RiccardoCh Jun 28 '17 at 12:31
  • 3
    Perhaps its a GPU issue, as there have been some of those (e.g., `WebView` still doesn't work IIRC). All I can suggest is creating a reproducible test case and [filing an issue](https://issuetracker.google.com/issues?q=componentid:192720%2B). – CommonsWare Jun 28 '17 at 13:59
  • I tried to remove background color on the others layout inside the CardView and in that case the rounded border are shown, but not the shadows, but the absence of shadows is noticeable in other ui elements, so it's probably a GPU issue, like @CommonsWare wrote. – RiccardoCh Jul 03 '17 at 12:30

1 Answers1

2

Hardware acceleration is turned off by default in Android Things. Add following to the manifest:

<application
    ...
    android:hardwareAccelerated="true">
4emodan
  • 955
  • 1
  • 9
  • 17