Change elevation at run-time, by calling setZ()

Change elevation at run-time, by calling setZ() - Hello Friend GENERAL INFO FOR ANDROID DEVELOPMENT, In the article you read this time with the title Change elevation at run-time, by calling setZ(), We have prepared this article for you to read and retrieve information there in. Hopefully the contents of postings Artikel elevation, Artikel Material Design, We write this you can understand. Alright, good read.

The Title : Change elevation at run-time, by calling setZ()
link : Change elevation at run-time, by calling setZ()

Read also


Change elevation at run-time, by calling setZ()

This example show how to change elevation of ImageView programmatically, by calling setZ().


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="16dp"
android:orientation="vertical"
tools:context="com.blogspot.android_er.androidzelevation.MainActivity">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:layout_gravity="center_horizontal"
android:autoLink="web"
android:text="http://android-er.blogspot.com/"
android:textStyle="bold"/>

<SeekBar
android:id="@+id/z"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:progress="20"
android:max="100"/>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="vertical"
android:gravity="center">
<ImageView
android:id="@+id/image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:elevation="20dp"
android:background="@android:color/background_dark"
android:src="@mipmap/ic_launcher"/>
</LinearLayout>

</LinearLayout>



package com.blogspot.android_er.androidzelevation;

import android.os.Build;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.ImageView;
import android.widget.SeekBar;

public class MainActivity extends AppCompatActivity {

SeekBar seekBarZ;
ImageView image;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

seekBarZ = (SeekBar)findViewById(R.id.z);
image = (ImageView)findViewById(R.id.image);

seekBarZ.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
image.setZ(i);
}
}

@Override
public void onStartTrackingTouch(SeekBar seekBar) {

}

@Override
public void onStopTrackingTouch(SeekBar seekBar) {

}
});
}
}


more:
elevation effect of overlapped view



Thus Article Change elevation at run-time, by calling setZ()

The End Article Change elevation at run-time, by calling setZ() This time, hopefully can give benefits to all of you. well, see you in posting other articles.

You are now reading the article Change elevation at run-time, by calling setZ() with the link address http://xorislogo.blogspot.com/2016/07/change-elevation-at-run-time-by-calling.html

0 Response to "Change elevation at run-time, by calling setZ()"

Post a Comment