2017-06-28 85 views
0

我已经使Raspberry Pi 3在Android上运行我的应用程序,但很多图形元素没有正确显示。我有一个RecyclerView,其中的布局包含一个CardView。 CardView没有正确显示,并且它被替换为一个简单的矩形。Android中的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

任何截图?或代码重现? https://stackoverflow.com/help/mcve – Blundell

+0

@Blundell重现这个问题,你需要安装在Raspberry Pi上的Andr oid东西以及CardView的布局 – RiccardoCh

+1

你的布局没有'CardView'。 – CommonsWare

回答

1

硬件加速默认情况下,在Android的东西关掉。将以下内容添加到清单中:

<application 
    ... 
    android:hardwareAccelerated="true">