Design material properties do not appear on API 19 apparatus

3

I've added the support library for APIs below 21 and am testing the elevation property on my components.

In layout view, when I click on the design tab, I can see the elevation but when I run to my smartphone does not change anything, it continues without any elevation.

Before adding the support I could not even use the property, so I do not understand how I can use it now and it does not 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'
    
asked by anonymous 18.08.2016 / 22:55

1 answer

3

Regarding "Material Design" not everything is supported by appcompat .

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

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

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

}

So the code is compatible with the lower versions, but the effect of elevation is only visible on Android devices with API21 or higher. The method is rewritten in implementation regarding API21 like this:

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

    ViewCompatApi21.setElevation(view, elevation);

}
    
18.08.2016 / 23:45