2015-11-07 94 views
0

我想在卡片視圖內的圖像後添加一些文字。 這是XML佈局我已經寫:如何在CardView中的圖像下添加文字

<android.support.v7.widget.CardView 
    xmlns:card_view="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    > 
    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical" 
     > 

     <ImageView 
      android:id="@+id/image_main" 
      android:layout_gravity="top" 
      android:layout_width="match_parent" 
      android:layout_height="250dp" 
      android:layout_alignParentLeft="true" 
      android:layout_alignParentTop="true" 
      android:src="@drawable/main_img" 
      android:scaleType="centerCrop" 
      /> 
     <TextView 
      android:id="@+id/info_text" 
      android:text="Hello World" 
      android:textAlignment="center" 
      android:textColor="@color/white" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      /> 
    </LinearLayout> 
</android.support.v7.widget.CardView> 

下面的文字不是圖像如下圖所示。僅顯示圖像和空白區域。如何糾正?

回答

0

你有

android:textColor="@color/white" 

而且我相信你使用

空白顯示白色背景

相關問題