我已经让Raspberry Pi 3在Android Things上运行我的应用程序,但很多图形元素都没有正确显示。我有一个RecyclerView,其中列出了包含CardView的项目列表。 CardView未正确显示,并被简单的矩形替换。
在普通的Android设备上一切正常。
这真的很奇怪,因为Android Things基于Android 7.0。 有没有人能够正确展示一切?
这是我的项目布局:
<?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>
答案 0 :(得分:2)
Android Things中默认关闭硬件加速。在清单中添加以下内容:
<application
...
android:hardwareAccelerated="true">