cardslib icon indicating copy to clipboard operation
cardslib copied to clipboard

TextOverImage background color

Open AshkanImmortal opened this issue 10 years ago • 2 comments

Hi, thanks for awesome library. using recycler view and Material card with image and text, as images coming from api may have different background color, I want to set a black overlay on textOverImage area then what ever color the image has the text with white color will be visible nicely, I searched your code and couldn't find any method or customization for that, even frameLayout containing that doesn't have id, can you help me?

AshkanImmortal avatar Feb 25 '15 12:02 AshkanImmortal

+1 to this issue. I'm not sure if there's anything to override in the xml either.

sartechb avatar May 29 '15 16:05 sartechb

Hey man, fortunately I implemented this :) you just have to change native_thumbnail_largematerial.xml from:

<ImageView
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/card_thumbnail_image"
        android:layout_height="match_parent"
        android:layout_width="match_parent"
        style="@style/card.native.card_thumbnail_image"/>

to this:

<RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <ImageView
            android:id="@+id/card_thumbnail_image"
            style="@style/card.native.card_thumbnail_image"
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="match_parent"
            android:layout_height="match_parent"/>

        <RelativeLayout
            android:id="@+id/newsImageTransparentLayer"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:background="@color/main_background">

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                android:src="@android:color/transparent"/>
        </RelativeLayout>
    </RelativeLayout>

I just put an imageView with transparent color (main_background = #77000000) over the original imageView, so the text could be nicely visible :) hope it helps

JGeraldoLima avatar May 30 '15 05:05 JGeraldoLima