Tag Archives: getWindow

How to create transparency in your activity or dialog in android – different methods?

By | March 16, 2013

There are different ways for making an acitivity transparent. First method 1. Through XML in AndroidManifest like this. [xml] <activity android:name="com.coderzheaven.interfacedemo.MainActivity" android:label="@string/app_name" <strong> android:theme="@android:style/Theme.Translucent"</strong> > </activity> [/xml] Here we are using Android’s built in theme. Method 2 Through styles create a style like this in your styles.xml [xml] <style name="Theme.Transparent" parent="android:Theme"> <item name="android:windowIsTranslucent">true</item> <item name="android:windowBackground">@android:color/transparent</item> <item name="android:windowContentOverlay">@null</item> <item… Read More »

Fling Gesture in Android

By | April 12, 2012

On implementing the onGestureListener you can get the events like Fling LongPress Scroll ShowPress SingleTap Its really simple, otherwise we have to calculate the distance between the touchdown and touchup event to check a fling event is happened or not. [java] import android.app.Activity; import android.os.Bundle; import android.view.GestureDetector; import android.view.MotionEvent; import android.view.View; import android.view.Window; import android.view.WindowManager; import android.view.GestureDetector.OnGestureListener; import… Read More »

Custom Title Bar in ANDROID

By | March 29, 2012

Hi all…. Today in this post I will show you how to give a custom layout for the titleBar in ANDROID. You can place almost anything inside a title using your custom layout. Now go on and create a fresh project and copy this code into the main java file [java] package pack.coderzheaven; import android.app.Activity; import android.os.Bundle; import… Read More »

How to place layouts one over another in android using addContentView()?

By | February 10, 2012

Hello all… In today’s tutorial I will show you how to add different layouts one over another in android through java code. For this we use the function addContentView() which is a variation on setContentView(View, android.view.ViewGroup.LayoutParams) to add an additional content view to the screen. Here I will create an xml with a textView and a Edittext and… Read More »

How to create a custom layout for your camera in Android?

By | December 28, 2011

Hello everyone, Today’s example shows how to create a custom layout for your camera preview, that is if you want a custom layout while your camera is opening. This example helps you to achieve this. First create a fresh project and name it CameraCustomLayout and copy this code to CameraCustomLayout.java file. [java] package com.coderzheaven.pack; import java.io.IOException; import android.app.Activity;… Read More »

How to show progress bar while loading a webpage in android?

By | November 3, 2011

This is a simple example showing how to load a webpage and show a progressBar while the page is loading in android. For that you have to set a chrome client for the webview which implements “onProgressChanged” Here is the layout file. [xml] <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <WebView android:id="@+id/webview" android:layout_width="fill_parent" android:layout_height="fill_parent"> </WebView> </LinearLayout>… Read More »

How to make your application FullScreen? or How to hide the Title-Bar in ANDROID?

By | April 3, 2011

This simple example makes your activity full screen by hiding the Title-Bar and gives more space for your application. [java] package pack.FullScreenActivity; import android.app.Activity; import android.os; import android.view.Window; import android.view.WindowManager; public class FullScreenActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.main); } } [/java] ;