Hi all

I am new in android, i am having few problem in layout alignment.I
have divide the screen into three layout,as header, body and footer.

I am giving the height dynamically for the three layout in java file,
so i need to give 12% of height to header and footer layout, and the
remaining 75% i need to assign height to body layout.

For that i have made the calculation as follow

first i am getting the height and width for the screen. With the help
of the screen height i am getting the 12.5% height for header and
footer layout

WindowManager w = getWindowManager();
Display d = w.getDefaultDisplay();
int totalwidth_screen = d.getWidth();
int totalheight_screen = d.getHeight();


int total_HF_screen = (int) ((12.5/100)*totalheight_screen); # height
for header and footer
int total_body_screen = totalheight_screen - (2*(total_HF_screen))
#height for body

By assigning the width and height for the layout using the above
calculations, iam not getting the footer layout properly.i.e only some
part of the footer is viewable.

I need to assign the height for the layout dynamically, which is not
comming using the above calculation.Can you please suggest me the apt
way of calculation for dynamically assigning the height of the
layout.

I have mention the xml file and java file for your reference



Xml file

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:id="@+id/widget0"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android"; >

        <LinearLayout
        android:id="@+id/header_aboutus"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/header">
        </LinearLayout>

        <LinearLayout
        android:id="@+id/body_aboutus"
        android:layout_width="fill_parent"
        android:layout_height="1dip"
        android:background="@drawable/body">
        </LinearLayout>

        <LinearLayout
        android:id="@+id/footer_aboutus"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:background="@drawable/footer">

                <Button
                android:id="@+id/aboutUs_home_button"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@drawable/home_button" >
                </Button>

        </LinearLayout>

</LinearLayout>



java file

import android.app.Activity;
import android.app.AlertDialog;
import android.content.Intent;
import android.os.Bundle;
import android.view.Display;
import android.view.View;
import android.view.WindowManager;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;

public class aboutus extends Activity {

        public String data;

        public void onCreate(Bundle icicle) {

                super.onCreate(icicle);
                setContentView(R.layout.aboutus);

                WindowManager w = getWindowManager();
            Display d = w.getDefaultDisplay();
            int totalwidth_screen = d.getWidth();
            int totalheight_screen = d.getHeight();


                int total_HF_screen = (int) ((12.5/100)*totalheight_screen);

                int total_body_screen1 =  2 * total_HF_screen;
                int total_body_screen = totalheight_screen - 
total_body_screen1;//
(int) ((75/100)* totalheight_screen);

               LinearLayout header_aboutus= (LinearLayout)
findViewById(R.id.header_aboutus);
                LinearLayout body_aboutus= (LinearLayout)
findViewById(R.id.body_aboutus);
                LinearLayout footer_aboutus= (LinearLayout)
findViewById(R.id.footer_aboutus);

                header_aboutus.setLayoutParams(
                                new LinearLayout.LayoutParams(totalwidth_screen,
total_HF_screen));
                body_aboutus.setLayoutParams(
                                new LinearLayout.LayoutParams(totalwidth_screen,
total_body_screen));
                footer_aboutus.setLayoutParams(new
LinearLayout.LayoutParams(totalwidth_screen, total_HF_screen ));

        }

}



Thanks
C.Rajesh

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to