簡體   English   中英

如何在CardView中的圖像下方添加文本

[英]How to add text below image in CardView

我想在卡片視圖內的圖像后添加一些文本。 這是我編寫的XML布局:

<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>

此處的文字未顯示在圖像下方。 僅顯示圖像和空白。 如何糾正呢?

你有

android:textColor="@color/white"

我相信你用白色背景

顯示空白

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM