--ADVERTISEMENT--

A android WebView is a View that displays any website to your android application. WebView also allows you to use HTML string, CSS and JavaScript design to your application. WebView embed website into your android application. WebView uses the WebKit rendering engine to display web pages and includes methods to navigate forward and backward through a history, zoom in and out, perform text searches and more.


Simple Android WebView Example


In this Simple Android WebView Example, I will teach you how to display website to your android application, enabling JavaScript and handling link clicks in your WebView. Let’s start step by step.

How to Load HTML Data/String on Android WebView Application

Implementing Navigation Back Feature to Android WebView Application

Simple Android WebView Example Demo:



Step 1: Creating Android Project:

Before jumping to our coding part let’s create a new android project for WebView Application with following information:
Application name: Simple Android WebView Example
Company Domain: sirseni.com
Package name: com.sirseni.simpleandroidwebviewexample
Minimum SDK: Android 2.2 (API 8 Froyo)


Step 2: Adding WebView to Your activity_main.xml file:

To add WebView to your application, you have to add <WebView> element to your xml layout. Simply copy and paste following code to your layout file.
res/layout/activity_main.xml

<webview android:id="@+id/myWebView" android:layout_height="fill_parent" android:layout_width="fill_parent" android:scrollbars="none" xmlns:android="http://schemas.android.com/apk/res/android">
</webview>

Step 3: Modify your MainActivity.java file:
To load your website in your application you have to use loadUrl().

WebView myWebView = (WebView)
findViewById(R.id.webview);
myWebView.loadUrl("http://www.example.com");


Here is complete code of your java file.

src/MainActivity.java

package com.sirseni.simpleandroidwebviewexample;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;

public class MainActivity extends Activity {

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

      
WebView myWebView = (WebView) findViewById(R.id.myWebView);
      
myWebView.loadUrl("http://www.centerend.com");
      
myWebView.setWebViewClient(new MyWebViewClient());
      
WebSettings webSettings = myWebView.getSettings();
      
webSettings.setJavaScriptEnabled(true);
    }

    // Use When
the user clicks a link from a web page in your WebView
    private class MyWebViewClient extends WebViewClient {
      
@Override
      
public boolean shouldOverrideUrlLoading(WebView view, String url) {
          
if (Uri.parse(url).getHost().equals("www.centerend.com")) {
              
return false;

            }
           
          
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
          
startActivity(intent);
          
return true;
        }
    }
}


How to Load HTML Data/String on Android WebView Application

Implementing Navigation Back Feature to Android WebView Application

Step 4: Modify AndroidManifest.xml file:
You must add the INTERNET permission to your AndroidManifest.xml file to load
website in your application. So before running your WebView application, add single line code to your Android Manifest file.

<uses-permission android:name="android.permission.INTERNET">
</uses-permission>
Final Code of AndroidManifest.xml


<manifest package="com.sirseni.simpleandroidwebviewexample" xmlns:android="http://schemas.android.com/apk/res/android">

    <uses-permission android:name="android.permission.INTERNET">

    <application android:allowbackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme">
        <activity android:label="@string/app_name" android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN">

                <category android:name="android.intent.category.LAUNCHER">
            </category></action></intent-filter>
        </activity>
    </application>

</uses-permission></manifest>
That’s all! Now run your Simple Android WebView Example application by just clicking Run icon, your application is looks like video presented below:


That’s all! Now run your Simple Android WebView Example application by just clicking Run icon, your application is looks like video presented below:



Download Complete Example Project

Download complete Simple Android WebView example project source code from GitHub.

In this tutorial, I am going to show how to create material design login form XML UI design. Many android applications have login and registration system. Here I have used only XML to create login screen. You have to create a drawable XML file for profile picture background color to make rounded. And you can use icons according to your wish here I have not provided icons. For EditText field icon should be small (24*24) to make attractive.

I have used TextInputLayout widget which is available in new android library called Design Support Library.

Related:
Simple Android Contact Form XML UI Design
Android EditText Example
Android AutoCompleteTextView and MultiAutoCompleteTextView

Android Example: Android Material Design Login Form XML UI Design


Let’s start by creating new android project with the project name Android Material Design Login Form or some else.

Import Design Support Library


In this project I have used TextInputLayout which is available in android design support library, so you have to add design support library in build.gradle file if not have.

build.gradle


XML Layout File


In XML layout file I have used RelativeLayout, LinearLayout, TextInputLayout, EditText, Button, ImageButton and TextView with different xml attribute to make material design login form UI design. Following is the complete content of XML layout file.

res/layout/ material_design_login_form.xml

XML Drawable File


Create a new XML file in res/drawable to make rounded in profile picture background. Following is the complete content of user_profile_image_background.xml file.

res/drawable/ user_profile_image_background.xml

Java Activity File


Default code of java activity file will look like this.

src/ MaterialDesignLogInForm.java

Strings.xml File


res/values/strings.xml

Android Example: Android Material Design Login Form XML UI Design

Now, run your Android Material Design Login Form XML UI Design application which will look like above screenshot.

Rounded android button can be used for many purposes to make awesome application. We can see many applications that have used circle button or rounded corner. In this tutorial, I am going to show how to make circular android button and to add icons/images and text in the same button.

To make circular button in android app, you don’t need any java code, this can be done by using only XML. Rounded button can also be created by using java code but it is time consuming and need to have advance knowledge of java programming.

Here you will learn to make circular/rounded corner button using XML only.

Related:
Android Button with Icon and Text
Adding Badge (Item Count) to Android Button
Android Switch Button Example

Android Example: How to Create Circular Button with Icon and Text in Android


First you have to create a new XML file in drawable folder to make rounded button. In this file I have made a rectangle and gave border radius to make circular and fill the background and border color. Following is the complete content of XML drawable file.

res/drawable/ circle.xml

XML Layout File


This is the XML layout file where I have added different buttons with image and text together and set background to the drawable file that we have created above. Following is the complete content of XML layout file.

res/layout/circular_button_with_image_and_text.xml

Java Activity File


Following is the default code of java activity file.

src/ RoundedAndroidButton.java

Strings.xml File


res/values/strings.xml

Android Example: How to Create Circular Button with Icon and Text in Android

Now, run your Circular Button with Icon and Text in Android application which will look like above screenshot. If you have any question please mention in the comment box below.

Displaying application intro/introduction slider or welcome screen in your android app is the best way of sowing major features of the app to the users at very first time. Only creating new android app is not difficult but how many users installed your app and among them how many users are active current is the most important thing. For that you have to focus on user experience and make app easy to use. App intro slider is one of the best way to show app features and ways to used them to the users.

Previously I have already wrote a tutorial about Splash Screen where you can display a single screen with short message like Welcome to Our App or some progressing activities. In this tutorial you will learn to display application intro screen with sliding function only for the first time. In the app intro slider, you can add as many screen as you like to show. And this is only display only first time to the user when they open app/game.

Related:
How to Make/Create a Splash Screen in Android
Display Images in Android GridView
Displaying Welcome Screen/Message in Android

Creating New Android Project


Let’s start making AppIntro Slider by creating a new project. Create a new project called Android App Introduction Slider using android studio or eclipse with empty activity.
Android AppIntro Slider Example

Adding Dependencies to your Bundle.gradle File


Open your app build.gradle file and add compile 'com.github.paolorotolo:appintro:4.1.0' dependency. Build.gradle will looks like this.
App build.gradle

And in your project build.gradle file you need to add mavenCentral() inside repositories.
Project build.gradle file:

Create AppIntro Sample Slider Class


Create a new class called AppIntroSampleSlider.java and extends Fragment. Following is the java code of AppIntroSampleSlider.java file you can directly copy and paste in your project.

src/AppIntroSampleSlider.java

Create XML Layout for App Intro Slider


Create three new xml layout files under res/layout folder and make app intro slider screens. Here I have added three screens in app intro and layout name are app_intro1.xml, app_intro2.xml and app_intro3.xml. If you want to show more screen in slider you can add according to your needs. Following are the three XML layout file for app info slider.
res/layout/app_intro1.xml

res/layout/app_intro2.xml

res/layout/app_intro3.xml

In above XML layout file I have added different layouts and views and three different images one in each file. Remember to change these images with your own.

Create New Custom Activity Class


Create a new java file called MyIntro.java and extends AppIntro. In this file you can control lots more things like animation type, show and hide Skip and status bar, vibration and lots more. Following is the complete content of MyIntro.java file.

src/MyIntro.java

If you want to change the animation type you can replace setDepthAnimation(); with setFadeAnimation(); or setZoomAnimation(); or setFlowAnimation(); or setSlideOverAnimation(); or setDepthAnimation(); or setCustomTransformer(yourCustomTransformer);

Update your MainActivity.java File


In this file you need to check first run time. Following is the complete content of MainActivity.java file.

src/ MainActivity.java

And default content of activity_main.xml file looks like this.
res/layout/activity_main.xml


Update Styles.xml File


Open your app res/values/styles.xml file and add full screen theme like below.
res/values/styles.xml

And don’t forget to change this in AndroidManifest.xml file. Android manifest file will looks like this.
AndroidManifest.xml

Colors.xml and Strings.xml File


Change the color value of colorPrimary, colorPrimaryDark, and colorAccent in res/values/colors.xml. Also add strings in res/values/strings.xml file. Colors.xml and strings.xml files will looks like below.

res/values/colors.xml


res/values/strings.xml

Now run your application which is looks like above screenshots. AppIntro slider is only visible for first time if you want to check once more you need to clear data from application info (settings/applications/application manager /choose appintro slider and click Clear Data button).

Download Complete Project Source Code


If you want to see complete source code, you can download all source code of this Android AppIntro Slider Example project from GitHub.

Though a small mobile phone in you hand looks simple and small. Have you ever wondered the fact that everything you can do in your handset has been possible by that large number of coding?  From having a touch effect to being able to run an application on that small phone has pages of language written. It has taken developers years to design a perfect coding for and android. They have been successful in a large manner but still don’t seem to be satisfied.  With every passing day a new page of code is coded and few libraries are added to allow your android for better functioning. So being a developer, approaching few best libraries is a basic thing to do.

Android libraries are just not so vast as is sound. Many of the themes, just adding a single line can add many functioning in your application. A code of one line can make your application communicate better, add a dragger, check the memory leakage and most importantly makes things logical and add annotation.

Top 7 Libraries Every Android Developer Should Know

Android libraries are available in large umber and easy to use. These different libraries have different features for you. But there are some regarded as best or most necessary for developers to approach due to their basic extraordinary functioning. We have analyzed a lot of such libraries to select these seven for you.



EventBus

For an android user, communication between applications they use is important.  This decouples event sender and recivers to simplify the communication. It claims that with few codes of EventBus you don’t need to you do not need to implement a single interface.
Get it on GitHub

Retrofit

This one is also the creation of github that changes your HTTP API into java script. So is the best solution for organization if API calls into a project.  The relative URL is added with annotation which by which you can add other parameters and manipulation as well.
Get it on GitHub

Leak Canary

This one is memory leak detection libraries designed for androids and Java. With just adding few lines to your exiting coding pages you can get to check and balance all the memory leaking spots. This apache listened library is something that you must approach as a developer.
Get it on GitHub

ACTIVEANROID

This one allows you to save and retrieve SQlite database without actually coding SQ. So, you can get and neatly wrapped data base, even without writing a single line.  It claims to take care of all setup and messy stuffs with simple sets of configuration.
Get it

Dragger
With the space coverage of just 100kb this github library has two parts that is dragger library and dragger compiler. It uses java. Inject annotation for making it portable. It is not fast and fancy but lightweight and simple enough to contain every necessary logics and some annotation.
Get it on GitHub

Picasso
It gives asynchronous library that allows hassle-free image loading in our android application with a coding of one single line.  It handles image view recycling, complex image transformation, including automatic memory and disk caching. It gives best API but supposed to be weaker in customization.
Get it on GitHub

Butter knife
This one was designed by Jake Wharton. This is a view binding library. It uses annotation process to generate boilerplate code to make things easier for you. It permits you for multiple views groups in a list.
Get it on GitHub

Conclusion
Being a developer is not an easy job. You need to understand the need of time and technology. Being up to dated is something basic for you as a developer. Android libraries are something just too basic for you to know. If you can understand the uses and effects of some libraries can give to your application, you can get a better result. Each library has its own unique features and way to perform its task.  Some are vast and some are of just few lines. Some can make your app work better while other may be unnecessary burden. So being a developer you much know to use the best android libraries.

Nowadays many android applications have login and registration screen. Everyone loves a beautiful login screen and mostly login screen is shown first, first impression about app is very important so we should design beautiful user friendly interface for login or registration screen.

In this tutorial, you will learn to create beautiful login and signup screen like Instagram android application using material design support library. You might have seen some apps used facebook, twitter, google/gmail, etc for login or registration, for that you need to integrate their SDK in your app.

Related:
Android XML Animations Examples
Chat/Messaging App XML UI Design for Android
Android Fragments Tutorial with Example


Android Material Design Tutorial: Instagram Style Login Screen XML UI Design


Instagram Style Android Login Screen XML UI Design


Let’s start by creating new android project called Instagram Login Screen and with package name: com.viralandroid.instagramloginscreen. Open your app build.gradle file and add android design support library dependencies. Your build.gradle file will looks like this:

Build.gradle

Modify Your Styles.xml File

Open styles.xml file and change app theme to Theme.AppCompat.Light.NoActionBar. Your app styles.xml file looks like below.

Styles.xml


Gradient Background

To make gradient background, create a new xml file in drawable directory called gradient_background.xml and gradient with angle, startColor, endColor, and type attributes inside
Instagram Style Login Screen XML Code

Create a new XML layout file called login_screen_layout.xml inside layout directory and add ImageView, TextInputLayout, EditText, TextView and Button inside LinearLayout. Don’t forget to add android:background attributes with @drawable/gradient_background in your root layout (LinearLayout). Editext contain different attributes like layout_width, layout_height, backgroundTint, drawableleft, hint, inputeType, textColor, textSize. All code of XML layout file will look like below.

res/layout/login_screen_layout.xml


Login Screen Java Activity File

This is the java code of LoginActivity.java file where we add setContentView to login_acreen_layout.

src/LoginActivity.java


MainActivity.java and activity_main.xml File

Open your activity_main.xml file and add a Button with an id, layout_width, layout_height, text attributes. XML layout file will look like below.

res/layout/activity_main.xml

And java activity file will look like below.

src/MainActivity.java


AndroidManifest.xml File

Android manifest file will look like below:

AndroidManifest.xml

Colors.xml file


Instagram Style Android Login Screen XML UI Design


We have created beautiful android login screen with material design like Instagram app. Now you can run by clicking Run button which looks like above screenshots.

Animated gradient background can be implemented in android app easily using XML and java code. Moving gradients background between different two or more gradients as animation makes your app more awesome. You may see this type of background color animation in instagram app. Instagram app keeps transforming background from one gradient to another beautifully.

You can easily add transforming gradients background in your android app easily using animation list. In this tutorial, you will learn to make moving gradient background in android using XML animator list and java code. You can add animation differently in android app but here we will show you one easiest way to add animation to your gradient background using XML.

Related:
Chat/Messaging App XML UI Design for Android
Drag and Drop Android Example
Simple Android Calculator App XML UI Design

How to Implement Transition Background Gradient

Animated Gradient Background in Android

First let’s start by creating new android project Animated Gradient Android as app name & viralandroid.com as company domain and rest of all things leave default.

Android Gradient Drawables

Now we will create different gradient drawables with different color and file name. Here we create gradient_1.xml, gradient_2.xml and gradient_3.xml XML drawable files with gradient attributes android:angle, android:endColor and android:startColor. Following is the XML code of three drawable files.

res/drawable/gradient_1.xml


res/drawable/gradient_2.xml



res/drawable/gradient_3.xml


Now create a new XML drawable file android_gradient_list.xml and add the following code which contains the AnimationList, which is responsible to change the background color from one gradient to another. In the AnimationList tag, add 3 items and referring to the above 3 XML drawable files.

res/drawable/android_gradient_list.xml


XML Layout File

Open your app main XML layout file activity_main.xml and set background to the root layout (View or ViewGroup) of the activity where you want to add animated gradient background. Also give an id to that layout; we will need to refer in java activity file.

res/layout/activity_main.xml


Java Activity File

In java activity file you need to tell the animation list to start moving transaction using AnimationDrawer.start methoad and animationDrawable.setEnterFadeDuration, animationDrawable.setExitFadeDuration and .getBackground.

src/MainActivity.java


Animated Gradient Background in Android

Animated Gradient Background in Android

Animated Gradient Background in Android

Now, run your app by clicking run button. You will see the animation between background gradient with different color like above screenshots.
Powered by Blogger.