ZieIony / Carbon

Material Design implementation for Android 4.0+. Shadows, ripples, vectors, fonts, animations, widgets, rounded corners and more.

Home Page:https://androidreclib.wordpress.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Incorrect displayed View

Shokhrukh1 opened this issue · comments

I migrated my project from 0.15.3 to 0.16.0.1. But I have problems with the view.

Here is my layout code

<carbon.widget.LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        tools:context=".MainActivity">

    <carbon.widget.FrameLayout
            android:layout_width="match_parent"
            android:layout_height="200dp"
            android:layout_marginLeft="16dp"
            android:layout_marginTop="25dp"
            android:layout_marginRight="16dp"
            android:layout_marginBottom="8dp"
            android:background="@android:color/white"
            android:shadowRadius="4"
            app:carbon_cornerRadius="4dp"
            app:carbon_elevation="12dp"
            app:carbon_elevationShadowColor="#80333333"/>
</carbon.widget.LinearLayout>

This is in 0.15.3 version
This is in 0.16.0.1 version

Carbon now uses MaterialShapeDrawable from Google's Material Components to draw shadows. It's faster than the previous method and doesn't need RenderScript - that's the reason for the change. It has it's own problems, but it's up to Google devs to fix it.

To fix your issue simply remove transparency from your elevation shadow color. Shadows don't support alpha values passed as shadow's color. I'll try to correct it, but for now removing the alpha component will help.

'android:shadowRadius' doesn't do anything - you can remove it from your xml. If I'm correct, it's an attribute used for drawing text shadows using setShadowLayer. Here's the correct xml:

<carbon.widget.LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        tools:context=".MainActivity">

    <carbon.widget.FrameLayout
            android:layout_width="match_parent"
            android:layout_height="200dp"
            android:layout_marginLeft="16dp"
            android:layout_marginTop="25dp"
            android:layout_marginRight="16dp"
            android:layout_marginBottom="8dp"
            android:background="@android:color/white"
            app:carbon_cornerRadius="4dp"
            app:carbon_elevation="12dp"
            app:carbon_elevationShadowColor="#333333"/>
</carbon.widget.LinearLayout>

I added a piece of code that sets alpha of the state list to 255 for all shadow colors. The code is in the repository.