Design material properties do not appear in API 19 appliance

Asked

Viewed 126 times

3

I added the support library for Apis below 21 and am testing the property elevation in my components.

In the layout view, when I click on the design tab, I can see the elevation but when I run to my smartphone nothing changes, everything continues without any elevation.

Before adding support I couldn’t even use the property, so I don’t understand how now I can use and it doesn’t work.

I added the lines in dependencies, in Gradle:

compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.android.support:design:22.2.1'

1 answer

3


With regard to the "Material Design" not everything is supported by appcompat.

In the case of elevation, it is only partially implemented.

To appcompat allows the use of the property, but it is not rendered in lower versions than API21.
The method setElevation(), class android.support.v4.view.Viewcompat, is implemented as follows (with nothing inside):

@Override
public void setElevation(View view, float elevation) {

}

Thus, the code is compatible with the lower versions, but the effect of the Elevation is only visible on Android devices with API21 or higher.
The method is rewritten in implementation concerning API21 thus:

@Override
public void setElevation(View view, float elevation) {

    ViewCompatApi21.setElevation(view, elevation);

}
  • So there’s no way I can have that effect of Elevation on Apis below 21? Because I can notice the shadow on some apps I have installed on the smartphone. They used some other feature?

  • Yes, possibly by resorting to 9-Patch drawables, see this

  • Thank you! Just one more question: using these effects I don’t need the Material Elevation right?

  • Yes, according to there say they run from API9 onwards

Browser other questions tagged

You are not signed in. Login or sign up in order to post.