Wednesday, 23 January 2013

Android Layout with Header Footer and scrollable Body content

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

    <LinearLayout
        android:id="@+id/header"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:padding="10dp" >

        <TextView
            android:id="@+id/TextView01"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="header"
            android:textSize="40sp" >
        </TextView>
    </LinearLayout>

    <LinearLayout
        android:id="@+id/footer"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:padding="10dp" >

        <TextView
            android:id="@+id/TextView02"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="footer"
            android:textSize="40sp" >
        </TextView>
    </LinearLayout>

    <ScrollView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_above="@id/footer"
        android:layout_below="@id/header" >

        <LinearLayout
            android:id="@+id/body"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical" >

            <EditText
                android:id="@+id/edit1"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:padding="10dp" />

            <EditText
                android:id="@+id/edit2"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:padding="10dp" />

            <EditText
                android:id="@+id/edit3"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:padding="10dp" />

            <EditText
                android:id="@+id/edit4"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:padding="10dp" />

            <EditText
                android:id="@+id/edit5"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:padding="10dp" />

            <EditText
                android:id="@+id/edit6"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:padding="10dp" />

            <EditText
                android:id="@+id/edit7"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:padding="10dp" />

            <EditText
                android:id="@+id/edit8"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:padding="10dp" />

            <Button
                android:id="@+id/btn"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:text="Submit" />
        </LinearLayout>
    </ScrollView>

</RelativeLayout>
 

Note : Add android:windowSoftInputMode="adjustPan" to your activity in Android manifest.

If it does not work then add the following in the oncreate method of the activity

getWindow().setSoftInputMode(
                WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);

output:

 

 

 

Monday, 21 January 2013

Invalid Project Description Eclipse Error

This error is due to overlapping of workspaces
To fix this create seperate folder in workspace and import your project there it works well

Wednesday, 16 January 2013

Lock footer at bottom(Layout arrangement)

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

    <!-- HEADER -->
    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
    />

    <!-- BODY -->
    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="0dip"
        android:layout_weight="1"
        android:orientation="vertical"
    />

    <!-- FOOTER -->
    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
    />
</LinearLayout>
</ScrollView> 
 
Note:Design the layout in the above manner and you 
will not get footer when user clicks edit textbox in UI 

Badge Effect in Android

package com.example.badge;

import android.os.Bundle;

import android.app.Activity;
import android.view.Menu;
import android.widget.TextView;

public class MainActivity extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        TextView tv1 = (TextView) findViewById(R.id.textView1);
       
       
               
       
    }

  
}


activity_main.xml

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/frameLayout1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" >

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/ic_launcher" />

    <TextView
        android:id="@+id/textView1"
        android:layout_width="20dip"
        android:layout_height="20dip"
        android:layout_gravity="top|right"
        android:background="@drawable/circle"
        android:gravity="center"
        android:padding="2sp"
        android:text="5"
        android:textColor="@android:color/black"
        android:textStyle="bold" />

</FrameLayout>


Circle.xml

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>

    <shape android:shape="oval"  >
        <solid android:color="@android:color/black" />
    </shape>

</item><item
    android:bottom="1dp"
    android:left="1dp"
    android:right="1dp"
    android:top="1dp">

    <shape android:shape="oval" >
        <solid android:color="@android:color/darker_gray" />
    </shape>

</item>
</layer-list>


Output

 


Pass a HashMap from Angular Client to Spring boot API

This example is for the case where fileData is very huge and in json format   let map = new Map<string, string>()      map.set(this.ge...