Post Top Ad

May 29, 2014

Android 3rd Tutorial: Layout Options FILL_PARENT, MATCH_PARENT , WRAP_CONTENT


• FILL_PARENT (renamed MATCH_PARENT in API Level 8 and higher), which means that the View wants to be as big as its parent (minus padding)
•WRAP_CONTENT, which means that the View wants to be just big enough to enclose its content (plus padding)
Either attribute can be applied to View's (visual control) horizontal or vertical size. It's used to set a View or Layouts size based on either it's contents or the size of it's parent layout rather than explicitly specifying a dimension.

fill_parent
(deprecated and renamed MATCH_PARENT in API Level 8 and higher)
Setting the layout of a widget to fill parent will force it to expand to take up as much space as is available within the layout element it's been placed in. It's roughly equivalent of setting the dock style of a Windows Form Control to Fill.
Setting a top level layout or control to fill parent will force it to take up the whole screen.

wrap_content
Setting a View's size to wrap content will force it to expand only far enough to contain the values (or child controls) it contains. For controls -- like text boxes (TextView) or images (ImageView) -- this will wrap the text or image being shown. For layout elements it will resize the layout to fit the controls / layouts added as its children.
It's roughly the equivalent of setting a Windows Form Control's Auto size property to True.

Online Documentation
There's some details in the Android code documentation here


May 29, 2014

Styling Android: Online Tools

As mobile developers Styling Android Application is the biggest pain. But thanks to this Online tool
you can reduce your hard times.

Try it,


Android Asset Studio

Icon generators — Make icons for your app

Icon generators allow you to quickly and easily generate icons from existing source images, clipart, or text.
May 29, 2014

What is an HttpHandler in ASP.NET

Once I got a interview question about ASP.NET HttpHandlers. By that time i didnt know what it refers to. Finally when i finished searching on it it narrowed down to what i already know.  So today ill share about HttpHandler in ASP.NET.

In the simplest terms, an ASP.NET HttpHandler is a class that implements the System.Web.IHttpHandler interface.

ASP.NET HTTP Handlers are responsible for intercepting requests made to your ASP.NET web application server. They run as processes in response to a request made to the ASP.NET Site. The most common handler is an ASP.NET page handler that processes .aspx files. When users request an .aspx file, the request is processed by the page through the page handler.

ASP.NET offers a few default HTTP handlers:

    Page Handler (.aspx): handles Web pages
    User Control Handler (.ascx): handles Web user control pages
    Web Service Handler (.asmx): handles Web service pages
    Trace Handler (trace.axd): handles trace functionality

You can create your own custom HTTP handlers that render custom output to the browser. Typical scenarios for HTTP Handlers in ASP.NET are for example
  
delivery of dynamically created images (charts for example) or resized pictures.
RSS feeds which emit RSS-formated XML

You implement the IHttpHandler interface to create a synchronous handler and the IHttpAsyncHandler interface to create an asynchronous handler. The interfaces require you to implement the ProcessRequest method and the IsReusable property.
The ProcessRequest method handles the actual processing for requests made, while the Boolean IsReusable property specifies whether your handler can be pooled for reuse (to increase performance) or whether a new handler is required for each request.
May 24, 2014

Android : Difference between px, dp, dip and sp

Most of the newbie's are bit complicated about how to handle images and font sizes in android, because
there are several terms relating to them. Today i hoped to discuss some of them. Here, i'll share most of the important information which i found referring developers site and others.    

  • px is one pixel.
  • sp is scale-independent pixels.
  • dip is Density-independent pixels.
You would use
  • sp for font sizes
  • dip for everything else.
dip==dp
px
Pixels - corresponds to actual pixels on the screen.

in
Inches - based on the physical size of the screen.

mm
Millimeters - based on the physical size of the screen.

pt
Points - 1/72 of an inch based on the physical size of the screen.

dp
Density-independent Pixels - an abstract unit that is based on the physical density of the screen. These units are relative to a 160 dpi screen, so one dp is one pixel on a 160 dpi screen. The ratio of dp-to-pixel will change with the screen density, but not necessarily in direct proportion. Note: The compiler accepts both "dip" and "dp", though "dp" is more consistent with "sp".

sp
Scale-independent Pixels - this is like the dp unit, but it is also scaled by the user's font size preference. It is recommend you use this unit when specifying font sizes, so they will be adjusted for both the screen density and user's preference.


More Description.

Screen size : Actual physical size, measured as the screen's diagonal. For simplicity, Android groups all actual screen sizes into four generalized sizes: small, normal, large, and extra large.

Screen density : The quantity of pixels within a physical area of the screen; usually referred to as dpi (dots per inch). For example, a "low" density screen has fewer pixels within a given physical area, compared to a "normal" or "high" density screen. For simplicity, Android groups all actual screen densities into four generalized densities: low, medium, high, and extra high.

Orientation : The orientation of the screen from the user's point of view. This is either landscape or portrait, meaning that the screen's aspect ratio is either wide or tall, respectively. Be aware that not only do different devices operate in different orientations by default, but the orientation can change at runtime when the user rotates the device.

Resolution : The total number of physical pixels on a screen. When adding support for multiple screens, applications do not work directly with resolution; applications should be concerned only with screen size and density, as specified by the generalized size and density groups.

Density-independent pixel (dp) :A virtual pixel unit that you should use when defining UI layout, to express layout dimensions or position in a density-independent way. The density-independent pixel is equivalent to one physical pixel on a 160 dpi screen, which is the baseline density assumed by the system for a "medium" density screen. At runtime, the system transparently handles any scaling of the dp units, as necessary, based on the actual density of the screen in use. The conversion of dp units to screen pixels is simple: px = dp * (dpi / 160). For example, on a 240 dpi screen, 1 dp equals 1.5 physical pixels. You should always use dp units when defining your application's UI, to ensure proper display of your UI on screens with different densities.



 

May 24, 2014

Android Google Maps Chapter 1


Android allows us to integrate google maps in our application. You can show any location on the map , or can show different routes on the map etc. You can also customize the map according to your choices.




Adding Google Map

Google provides this facility using google play services library which you have to download externally. After downloading , you have to integrate it with your project.In the end you have to integrate your application with google via google console. This is completely discussed in the example.

Google Map - Activity file
Google provides GoogleMap and MapFragment api to integrate map in your android application. In order to use GoogleMap , you have to create an object of GoogleMap and get the reference of map from the xml layout file.Its syntax is given below:

GoogleMap googleMap;
googleMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap()

Google Map - Layout file

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >
   </LinearLayout>

AndroidManifest file



    android:targetSdkVersion="17" />
    <permission android:name="com.example.testmapv2.permission.MAPS_RECEIVE"
     android:protectionLevel="signature"></permission>
    <uses-permission android:name="com.example.testmapv2.permission.MAPS_RECEIVE"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
    
       <uses-feature
        android:glEsVersion="0x00020000"
        android:required="true" >
    </uses-feature>
       <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
       <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.example.testmapv2.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
                
            </intent-filter>
        </activity>
        <meta-data android:name="com.google.android.maps.v2.API_KEY"
            android:value="key"/>
        <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />

   


-------------------------------------------------------------------------------------------------------------------------------  
 
In the next tutorial we will discuss how to generate the key file using Eclipse IDE.
       



 

 

My Instagram