开发者

Help with stacked layout

I am trying to make a stacked layout with a fixed header, expandable body and fixed footer. I am very close however the body section with the webview displays behind the footer rather than between the header and footer. TIA

Jim

<?xml version="1.0" encoding="utf-8"?>

 <LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
   android:id="@+id/header"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

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

    <ImageView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:src="@drawable/icon" />


  <TextView  
      android:layout_w开发者_高级运维idth="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="Karen" />

 </LinearLayout>

 <RelativeLayout
   android:layout_width="wrap_content" 
      android:layout_height="fill_parent"
      android:layout_below="@id/header"
      >


 <WebView 
     android:id="@+id/webview"
     android:layout_width="fill_parent"
     android:layout_height="wrap_content"
     android:background="#000000"
  />

 <LinearLayout
 android:id="@+id/footer"
 android:layout_width='fill_parent'
 android:layout_height="wrap_content"
 android:layout_alignParentBottom="true"
 android:orientation="horizontal"
 android:background="#000000"
>

<EditText 
 android:id="@+id/inputText"
 android:layout_width="wrap_content"
 android:layout_height="fill_parent"
    android:text="Is on the bottom"
    android:layout_weight="1"
    android:textSize="15sp"
    /> 

 <Button
  android:layout_width="wrap_content"
 android:layout_height="fill_parent"
  android:textSize="15sp"
 android:text="send" />

 </LinearLayout>


 </RelativeLayout>

</LinearLayout>


I am trying to make a stacked layout with a fixed header, expandable body and fixed footer

Step #1: Make the root layout a RelativeLayout.

Step #2: Add the header as a child of the RelativeLayout, anchored to the top (android:layout_alignParentTop="true")

Step #3: Add the footer as a child of the RelativeLayout, anchored to the bottom (android:layout_alignParentBottom="true")

Step #4: Add the body as a child of the RelativeLayout, anchored to the header (android:layout_below="...") and footer (android:layout_above="...")


SOLVED.

I needed to reorder the items in the .xml file by putting the center item (webview) at the bottom and add android:layout_above="@id/footer".

I learned that when android processes id's they must be defined prior to using then in directives such as android:layout_above="@id/footer".

This is much like javascript processing on page load, the functions have to be defined prior to execution.

BTW thanks to everyone at StackOverFlow, you make this an invaluable resource to developers.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜