--ADVERTISEMENT--

Android allows us to access the camera LED/ Flashlight/ Touchlight in our application. You can turn ON and OFF flashlight from your application using java code. Most of the time android flash light is on while taking photos in flash mode. In this tutorial, you will learn how to turn ON and OFF camera LED/ flashlight programmatically from your android app.

To work with android flashlight/touch light, you have to add the permission to access camera and hardware in your application AndroidManifest.xml file.

This is simple turn on and off flashlight android application; here is no any complex code you just have to add little bit java code. Here, I have used toggle button to turn on and off flashlight.

Related:
Turn ON and OFF WiFi Connection Programmatically in Android
Android ToggleButton and Switch Button Example
Android CheckBox Example

Android Example: Turn On and Off Camera LED / Flashlight Programmatically


Following is the step by step guide to turn on/off flashlight programmatically in android.


Create a new Android Project


Let’s start by creating a new project to turn on/off camera led/flashlight programmatically with following information.

Application name: Turn On and Off Android Flashlight
Company Domain: viralandroid.com
Package name: com.viralandroid.turnonandoffandroidflashlight

Adding Permission


Open your app AndroidManifest.xml file and add android.permission.CAMERA and android.hardware.camera permission. AndroidManifest.xml file will looks like this.

AndroidManifest.xml


XML Layout File


Following is the content of XML layout file where I have added a toggle button to turn on and off flash light programmatically from android app.

res/layout/turn_on_off_camera_flash_light.xml


Java Activity File


Following is the simple java code to develop android flash light application.

src/ OnOffCameraFlashlight.java

Strings.xml File


res/values/strings.xml

Android Example: Turn On and Off Camera LED / Flashlight Programmatically

That’s all. Now run your Turn On and Off Camera LED / Flashlight Programmatically in Android application and click the toggle button to turn on and off flashlight of your phone. Make sure to work by this example, your device should have the flash light.

Nowadays users are interacting with material design application. Material design applications are eye catching app which uses some effects like animation and material color to their app. If you are looking to make show and hide a view with a scroll or slide down and up screen with animate effect to android image view, text view or custom view, you are in right place. In this tutorial, you will learn to show and hide any android view when scroll/slide the screen with animation effect.

Here all these animations are made only by using XML code, you not need to have knowledge of java programming during this time.

Related:
How to Hide Toolbar/AppBarLayout When Content Scroll
Create Scrolling Text (Marquee) in Android TextView
Hide and Show Android ActionBar in Any Activity

Android Example: How to Show and Hide a View with a Slide Up/Down Screen with Animation


First things you have to do is open build.gradle file of your app and add compile 'com.github.flavienlaurent.discrollview:library:[email protected]' as project dependency. Build.gradle file will look like below.

build.gradle

Now we will be working in XML layout file and all things will be done here. Open your project XML layout file and change your root layout to com.flavienlaurent.discrollview.lib.DiscrollView and add a new widget com.flavienlaurent.discrollview.lib.DiscrollViewContent inside that layout with layout_height and layout_width match_parent attributes. All content/widgets/views that you want to animate goes inside second widget with different attributes. Following is the complete content of sample project example you can paste below code to your project XML layout file.

res/layout/animated_scrolling_android_imageview.xml

Following is the default code of java activity file.

src/AnimatedAndroidTextViewEffect.java


Now, run your Show and Hide Android Views When Scroll the Screen With Animation Effect application and scroll down and up the screen you will see different views with different animation effect. This will look like the above gif demo.

In this tutorial, you will learn to select time in android application using TimePicker widget and display the time. This time picker allows you to pick time by hour and minute.

Related:
Android Radio Button Example
Android Switch Button Example
Android Spinner Example

Android Example: How to use TimePicker in Android App


This example gives you the instructions to use TimePicker in android.

XML Layout File

res/layout/activity_main.xml

Java Activity File

src/MainActivity.java

Strings.xml File

res/values/strings.xml

Now, run your time picker application which will look like this.

Android Time Picker Example
Time Picker

In this tutorial, I am going to show how to implement image view images zoom effect in android application. Implementing zoom effect in android ImageView images is not very easy, it’s little bit complex. You can find same type of project in android developer site, inside Building Apps with Graphic and Animation topic.

When you touch or click on the image it starts zooming, this type of zooming animation can be used in photo gallery. To make zoom in image in XML layout file two ImageView components are used; one for thumbnail and another for large image. The large imageview is for full screen size and small imageview is for thumbnail size.

Related:
How to Add Ripple Effect/Animation to a Android Button
Blinking Animation in Android Application
Android ImageSwitcher Example

Android Example: How to Implement Zooming Effect in Android ImageView Images


Here you will find all necessary code to make zoom in android image view images. There are only two important files; one is XML layout file and another is java activity file and then you have to add one image in your project drawable folder.

XML Layout File

Following is the complete content of XML layout file, here you will find two ImageView inside FrameLayout.
res/layout/android_image_zoom_effect.xml

Java Activity File

Following is the complete content of java activity file to make android ImageView images zoom effect/animation. This is little bit complex. You can copy and paste in your project directly for first time.
src/AndroidImageZoomEffect.java


Strings.xml File

Following is the default content of strings.xml file.
res/values/strings.xml


How to Implement Zooming Effect in Android ImageView Images

You have done all things. Now, run your Implement Zooming Effect in Android ImageView Images project and touch on the image, image will start zoom in with animation. Make sure that you have added an image in drawable folder and name it cat or replace cat with your image name in XML layout file and java activity file.

Circular progress bar/ loader can be shown at the time of loading content from the server/internet like twitter android app has, refreshing the page like gmail android app. Not only that circular progress/loader can be used to show downloading, uploading progress and many other purpose. In this tutorial, you will learn to make material design progress bar for android application/game.

Implementing material design progress bar in android is not much difficult to implement in apps or game if you have some knowledge of android app development.

Related:
Material Design Horizontal ProgressBar Android Example
Simple Creating Circular ProgressBar in Android
Dashboard UI Design for Android App

Android Example: How to Make Material Design Progress/Loader


Let’s start by adding compile 'com.github.rey5137:material:1.2.2' dependency to your app build.gradle file. Build.gradle file will look like below.

build.gradle

XML Layout File

I am making this material design progress using ProgressView widget so open your app’s XML layout file and add ProgressView widgets. Following is the complete content of XML layout file.

res/layout//material_design_circular_progressbar.xml

Java Activity File

Following is the modified code of java activity file.

src/MaterialDesignAndroidCircularProgress.java

Android Example: How to Make Material Design Progress/Loader

Now run your Material Design Circular ProgressBar For Android application, the progress/loading will start automatically after running app.

Android TextView allows user to display text in android application. In this tips, I will show how to make scrollable TextView in android. To make TextView scrollable, you don’t need to use ScrollView, just add android:scrollbars=”vertical” attribute in TextView and then add two line of code in your java activity file.

Related:
How to Align Android TextView in the Center of the Screen
How to Set Android Button and TextView Border Color
Android Material Design with Design Support Library

XML Layout File

Following is the xml layout file which contain a LinearLayout and a TextView.
res/layout/scrollable_textview.xml

Java Activity File

Following is the final code of MainActivity.java file.
src/MainActivity.java

Now, run your application and see texts are scrolling.

Output:

How to Make Scrollable TextView in Android
Scrollable TextView

SeekBar is the extension of ProgressBar in android. In this tutorial, I am going to show how to customize android SeekBar. There are lots of ways to customize SeekBar and here I have mentioned idea to customize SeekBar with the help of XML. To control the event handling method for SeekBar, you have to use seekBar.setOnSeekBarChangeListener(………….).

Related:
Android SeekBar Example
Android Radio Button Example
Android Layouts Tutorial

Android Example: How to Customize Android SeekBar


Let’s start by creating seekbar_progressbar.xml file in your res/drawable directory and add this content.
res/drawable/seekbar_progressbar.xml

And download the below seekbar-thumb.png image and paste it in your project drawable folder.

SeekBar thumb image
seekbar-thumb.gng

XML Layout File

Following is the xml layout file where I have added a and added some new attributes in SeekBar.
res/layout/activity_main.xml

Java Activity File

src/MainActivity.java

Now, run your application, which looks like output given below.

Output:


Android Custom SeekBar Example

Powered by Blogger.