SimpleDraweeView round corners in XML - android

I'm trying to round specific corners of image using Fresco lib.
As shown in the pic, how to round the bottom left corner of the image.
Here is the xml:
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="#+id/cardview"
android:layout_width="match_parent"
android:layout_height="180dp"
android:layout_marginBottom="4.0dp"
android:layout_marginLeft="8.0dp"
android:layout_marginRight="8.0dp"
android:layout_marginTop="4.0dp"
card_view:cardCornerRadius="5dp"
card_view:cardPreventCornerOverlap="false"
>
<com.facebook.drawee.view.SimpleDraweeView xmlns:fresco="http://schemas.android.com/apk/res-auto"
android:id="#+id/image1"
android:layout_width="145dp"
android:layout_height="180dp"
fresco:placeholderImage="#color/pink"
fresco:roundedCornerRadius="5dp"
fresco:roundBottomRight="false"
fresco:roundTopRight="false"
fresco:roundBottomLeft="true"/>
</android.support.v7.widget.CardView>

If you have in your parent layout xmlns:app="http://schemas.android.com/apk/res-auto" and xmlns:fresco="http://schemas.android.com/tools" use
app:roundedCornerRadius="5dp"
instead
fresco:roundedCornerRadius="5dp"

You don't need to use CardView.
Use following lines, according to your requirement:
fresco:roundTopLeft="true"
fresco:roundTopRight="false"
fresco:roundBottomLeft="false"
fresco:roundBottomRight="true"
fresco:roundTopStart="false"
fresco:roundTopEnd="false"
fresco:roundBottomStart="false"
fresco:roundBottomEnd="false"
For reference

I think your image is going out of your CardView area and that is creating problem.
You can try out by giving your CardView height as wrap_content and give slight padding_left and padding_bottom to SimpleDraweeView

Related

Set white glow on cardview

I presume, this is quite a basic question but I had to ask it because of my attempt for finding relevant answers for setting white glow on MaterialCardView or simply CardView goes in vain, They were offering setting border color instead, now anyone please bother yourself to enlighten me with the proper solution.
I have a green glow around white cardview
Try this code
<android.support.v7.widget.CardView
card_view:cardBackgroundColor="#color/green"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
card_view:cardCornerRadius="10dp"
card_view:cardElevation="5dp"
card_view:cardUseCompatPadding="true">
<android.support.v7.widget.CardView
android:layout_margin="3dp"
android:id="#+id/card_view"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
card_view:cardBackgroundColor="#color/white"
card_view:cardCornerRadius="10dp"
>
</android.support.v7.widget.CardView>
</android.support.v7.widget.CardView>
Use 9-patch image like this one:
and apply it to a FrameLayout, then put your content with white background inside
Or for API 28+ you can try using android:outlineSpotShadowColor="#5500FF00" attribute

Rounded corners on StreetViewPanoramaView?

I have a dialog which contains a CardView with cornerRadius set, StreetViewPanoramaView is at top, but top corners are square, I guess it's a SurfaceView, any hint about how to make the corners round above StreetViewPanoramaView?
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:clipChildren="true"
app:cardBackgroundColor="#color/white"
app:cardCornerRadius="16dp">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<com.google.android.gms.maps.StreetViewPanoramaView
android:id="#+id/street_view"
android:layout_width="match_parent"
android:layout_height="150dp" />
[...]
Try app:cardUseCompatPadding="true" maybe help you I am not sure because I used with another component not StreetViewPanoramaView so please try it.

Extra padding at top and bottom in CardView

I'm using to recyclerview to display a list a images from a web service. I'm trying to display images in ImageView within CardView widget.Everything is working fine. All the images and lists are displaying properly. but when i try to run on Kitkat 4.4.4 its showing extra(Large) padding at top and bottom of image within the Cardview. I'm using ImageView only no text nothing.
Check the attached image.
on 4.4.4
on Lollipop
I've tried almost everything that i've found on SO so far.
any help is appreciated.
Thanks
XML code for Cardview
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:card_view="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/activity_horizontal_margin_half">
<android.support.v7.widget.CardView
android:layout_centerHorizontal="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/offwhite"
android:id="#+id/cardlayout_malls"
android:layout_marginLeft="#dimen/activity_horizontal_margin_half"
card_view:cardUseCompatPadding="true"
android:layout_marginRight="#dimen/activity_horizontal_margin_half">-->
<!-- Thumbnail Image -->
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/bannerImageView"/>
</android.support.v7.widget.CardView>
</RelativeLayout>
try this way
card_view:cardPreventCornerOverlap="false"
OR
in imageview you can use add this in your imageview
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:id="#+id/bannerImageView"/>
addcard_view:cardPreventCornerOverlap="false"
Extra padding is because of those tiny round corners which, need to be disabled. Basically that is not a flaw rather a Design constraint!

Android: why are CardView margins not showing white background?

I have set up a CardView in a RecyclerView list. The layout_marginTop and layout_marginBottom are showing a grey color rather than the white background I had hoped to see (image below). Any ideas on how to get the top and bottom margins to show a white background?
<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/card_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
card_view:cardCornerRadius="6dp"
android:layout_margin="4dp">
<TextView
android:id="#+id/cardText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_marginBottom="20dp"
android:background="#android:color/white" />
</android.support.v7.widget.CardView>
Removed the TextView background and added this background to the CardView:
"card_view:cardBackgroundColor="some color""
Add some margin to card
<android.support.v7.widget.CardView
android:id="#+id/cardView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="7dp"
app:cardCornerRadius="2dp"
app:cardElevation="4dp">
</android.support.v7.widget.CardView>
Make sure you're actually populating it with data from your domain model, i.e. check that you've implemented <data> and <variable> tags and that you've set your android:text="#{}" to the appropriate object.

CardView ignoring android:clipChildren="false"

I want to have a CardView which contains an ImageView which overlaps the left border of the CardView.
I want to do this by giving the ImageView a negative margin.
This works fine with all other layouts (LinearLayout/RelativeLayout/FrameLayout) by setting clipChildren="false".
However I can't get it to work with a CardView.
The ImageView will be clipped and does not overlap the CardView.
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:clipChildren="false">
<ImageView
android:layout_marginLeft="-10dp"
android:background="#drawable/some_picture"
android:layout_width="50dp"
android:layout_height="50dp"/>
</android.support.v7.widget.CardView>
Ok, this seems to be a problem only with Android 5+, the solution is to set
cardView.setClipToOutline(false);
Source - https://www.reddit.com/r/androiddev/comments/2tccge/cant_draw_outside_of_cardview_parent/
Add this to your MaterialCardView xml file
android:outlineProvider="none"
wrap it in LinearLayout with param LinearLayout
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipChildren="false">
<android.support.v7.widget.CardView/>
</LinearLayout>
Add:
android:clipChildren="false"
to CardView's grandfather View.

Categories

Resources