How to change application: elevation programmatically

My application works for API 19. Therefore, I cannot use android: elevation. So I app: height in my layout.

Android XML: android: elevation versus application: height

For instance:

<android.support.design.widget.AppBarLayout
    android:id="@+id/appBar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:theme="@style/AppTheme.AppBarOverlay"
    app:elevation="5dp">

How to change application: elevation programmatically? I can change android: height, but I can not find how to change application: elevation!

+4
source share
4 answers

Try using the following code

ViewCompat.setElevation(View, int)

Following the link below. Here is how to elevate to the preglacial device.

Antenna AppCompat 21 Elevation

+13
source

, , API 19

getSupportActionBar().setElevation(0);

, Android API 21

AppCompat 21 Elevation

+3

.

,

app:elevation="0" AppBarLayout xml

mAppBarLayout.setTargetElevation(0) java.

.

0

NativeScript

let nativeAnView = tnsView.android;
var shape = new android.graphics.drawable.GradientDrawable();
shape.setShape(android.graphics.drawable.GradientDrawable.OVAL);
shape.setColor(android.graphics.Color.parseColor('#30bcff'));
nativeAnView.setBackgroundDrawable(shape);
nativeAnView.setElevation(20);

Android

let nativeView = tnsView.ios;
nativeView.layer.shadowColor = new Color('#888888').ios.CGColor;
nativeView.layer.shadowOffset = CGSizeMake(0, 2.0);
nativeView.layer.shadowOpacity = 0.5;
nativeView.layer.shadowRadius = 5.0;

iOS

0

All Articles