I'm doing an android app and I want to separate layout in 3 parts like this:
but now the button is over the second listview but on the bottom of the screen, I don't know why.
I don't know if I have to use relativeLayout or linearLayout to including the listviews, and text are inside this or outside of relativelayout/linearLayout, and the last button what?
this is my code:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView android:id="#+id/imageSelected"
android:text="#string/imgSelected"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_marginBottom="3dip"/>
<LinearLayout
android:id="#+id/linearLayoutImagenes"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_below="#+id/imageSelected" >
<ListView
android:id="#+id/listaFusionPhotos"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
</LinearLayout >
<TextView android:id="#+id/nameSelected"
android:text="#string/namSelected"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_below="#+id/linearLayoutImagenes"
android:layout_marginBottom="3dip"/>
<LinearLayout
android:id="#+id/linearLayoutNombres"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_below="#+id/nameSelected"
>
<ListView
android:id="#+id/listaFusionNombres"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
</LinearLayout >
<Button
android:id="#+id/fusion"
android:layout_width="160dip"
android:layout_height="wrap_content"
android:layout_below="#+id/linearLayoutNombres"
android:layout_marginTop="3dip"
android:text="Fusionar"
android:onClick="Mostrar_Registrados"
android:layout_alignParentBottom="true"/>
</RelativeLayout>
Try this. this looks like exactly same of the picture.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="11" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_weight="1"/>
<ListView
android:id="#+id/listView1"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="4">
</ListView>
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium" />
<ListView
android:id="#+id/listView2"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="4">
</ListView>
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:text="Button" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayoutNombres"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_below="#+id/nameSelected"
android:layout_above="#+id/fusion" // "line added"
>
<Button
android:id="#+id/fusion"
android:layout_width="160dip"
android:layout_height="wrap_content"
android:layout_below="#+id/linearLayoutNombres" --> "remove this line"
android:layout_marginTop="3dip"
android:text="Fusionar"
android:onClick="Mostrar_Registrados"
android:layout_alignParentBottom="true"/>
Related
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/main_bg"
>
<RelativeLayout android:layout_width="fill_parent"
android:layout_height="47dip" android:layout_alignParentTop="true"
android:background="#drawable/tab_bar" android:id="#+id/rel_jobDesc">
<TextView android:layout_width="wrap_content" android:id="#+id/txt_SEARCH_TITLE"
android:layout_height="wrap_content" android:layout_centerInParent="true"
android:text="Description" android:textStyle="bold" android:textSize="20dip"
android:textColor="#fff"></TextView>
</RelativeLayout>
<ListView
android:id="#+id/list"
android:cacheColorHint="#00000000"
android:layout_marginTop="60dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/job_match_bg" >
</ListView>
<Button
android:id="#+id/btn_more"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#drawable/viewmore"
android:layout_centerHorizontal="true"/>
</RelativeLayout>
I am new i android developement and i don't have idea to develop this plz help
and also i want to add at Bottom
textView width fiil_parent
and left Button and text at center and right Button
sorry for bad English Any help is appreciated.
Thank you in advance
moreButton
textView
L-Button text R_button
if you are looking for L-Button Text R-Button you need to add a linearLayout horizontally, then add a button- text- button and add weights to them to make it look nicer try this code:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/main_bg"
>
<RelativeLayout android:layout_width="fill_parent"
android:layout_height="47dip" android:layout_alignParentTop="true"
android:background="#drawable/tab_bar" android:id="#+id/rel_jobDesc">
<TextView android:layout_width="wrap_content" android:id="#+id/txt_SEARCH_TITLE"
android:layout_height="wrap_content" android:layout_centerInParent="true"
android:text="Description" android:textStyle="bold" android:textSize="20dip"
android:textColor="#fff"></TextView>
</RelativeLayout>
<ListView
android:id="#+id/list"
android:cacheColorHint="#00000000"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/linearLayout1" //*** this is important to make the list float over button-text-button
android:layout_below="#+id/rel_jobDesc"
android:background="#drawable/job_match_bg" >
</ListView>
<LinearLayout // here what you care about
android:id="#+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
>
<Button
android:id="#+id/btn_more"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:text="Left" />
<TextView
android:id="#+id/Left"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="TExt!!"
/>
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:text="Right" />
</LinearLayout>
</RelativeLayout>
you should have the following PIC: P.S: I dont have the pics so i changed the background color
Get the idea, and stir the code the way you like. if you didnt get the idea, feel free to ask me. Hope I got what you want.
---------------------------------Edit------------------------------------------
here is to add a new line above the linearLayout and under the ListView
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/main_bg"
>
<RelativeLayout android:layout_width="fill_parent"
android:layout_height="47dip" android:layout_alignParentTop="true"
android:background="#drawable/tab_bar" android:id="#+id/rel_jobDesc">
<TextView android:layout_width="wrap_content" android:id="#+id/txt_SEARCH_TITLE"
android:layout_height="wrap_content" android:layout_centerInParent="true"
android:text="Description" android:textStyle="bold" android:textSize="20dip"
android:textColor="#fff"></TextView>
</RelativeLayout>
<ListView
android:id="#+id/list"
android:cacheColorHint="#00000000"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/AboveLinear" //*** this is important to make the list float over button-text-button
android:layout_below="#+id/rel_jobDesc"
android:background="#drawable/job_match_bg" >
</ListView>
<TextView //this is the text the is between linear and list
android:id="#+id/AboveLinear"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/linearLayout1"
android:layout_centerHorizontal="true"
android:text="Right here what ever you want" />
<LinearLayout // here what you care about
android:id="#+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
>
<Button
android:id="#+id/btn_more"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:text="Left" />
<TextView
android:id="#+id/Left"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="TExt!!"
/>
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:text="Right" />
</LinearLayout>
</RelativeLayout>
it will look like this:
Glad I could help, Please be aware of the ID i gave to the components
use this property for for button
android:layout_alignBottom="#+id/list"
I have requirement of adding button behind single image. My main.xml is mentioned below. I am trying to create button3 for abcimage as shown below. I want this button at left center. How it can be done?
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#android:color/black">
<TableLayout
android:id="#+id/TableLayout01"
android:stretchColumns="*"
android:layout_height="wrap_content"
android:layout_width="fill_parent">
<TableRow
android:id="#+id/TableRow01"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_gravity="center_vertical|center_horizontal">
<ImageView
android:id="#+id/ImageView2_Left"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:src="#drawable/abcimage"></ImageView>
<Button
android:id="#+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:text="buyabc"
/>
</TableRow>
</TableLayout>
</LinearLayout>
Try this layout:
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<ImageView
android:id="#+id/ImageView2_Left"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:src="#drawable/abcimage" >
</ImageView>
<Button
android:id="#+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="buyabc" />
</RelativeLayout>
Use a FrameLayout which contains your image and your button:
<FrameLayout
android:id="#+id/TableRow01"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal" >
<ImageView
android:id="#+id/ImageView2_Left"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:src="#drawable/abcimage" >
</ImageView>
<Button
android:id="#+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="buyabc" />
</FrameLayout>
I am developing an Android Application and I have an Activity that looks like this. I have a header and a footer that have fixed positions, and a ListView with clickable items in the middle. Below the ListView, I have a button.
It is working when I have a few items, but as I add more items, the button begins to disappear, like this.
When I have more items in that list that can be shown in the page, I have a scroll in the list. If I scroll down like this I can see all the items in the list, but the button is hidden.
I have had a lot of problems before trying to add a ListView inside a ScrollView, so I know it doesn't work. As I am new in Android development, perhaps my XML layout files are a bit confusing, but I have a parent LinearLayout with two RelativeLayouts inside, one for the header and one for the middle and footer. The XML is something like this:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#FFFFFF">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="#drawable/background"
android:gravity="center_vertical">
<TextView
android:id="#+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:text="#string/baseTitle"
android:textColor="#FFFFFF"
android:layout_centerVertical="true"
android:textSize="18dp"
android:textStyle="bold"/>
<Button
android:id="#+id/buttonHelp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:background="#drawable/button_help"
android:layout_centerVertical="true"
android:layout_alignParentRight="true"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_gravity="fill_vertical">
<LinearLayout
android:id="#+id/buttonBar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:gravity="center"
android:background="#bdbdbd"
android:layout_alignParentBottom="true">
<RelativeLayout
android:id="#+id/bottomButtomBar"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:orientation="horizontal">
<Button
android:id="#+id/myGroups"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:text="#string/myGroups"
android:gravity="center"
android:textSize="13dp"
android:textColor="#000000"
android:background="#layout/button_meus_grupos"/>
<Button
android:id="#+id/createGroups"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_centerInParent="true"
android:text="#string/createGroups"
android:gravity="center"
android:textSize="13dp"
android:textColor="#000000"
android:background="#layout/button_criar_grupos"/>
<Button
android:id="#+id/configurations"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="15dp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:text="#string/configurations"
android:gravity="center"
android:textSize="13dp"
android:textColor="#000000"
android:background="#layout/button_configuracoes"/>
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:layout_above="#id/buttonBar"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout
android:id="#+id/listContent"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#ffffff"
android:orientation="vertical"
>
<RelativeLayout
android:id="#+id/searchBarLayout"
android:layout_width="fill_parent"
android:layout_height="48dp"
android:orientation="horizontal"
android:background="#ffffff"
android:gravity="center_vertical"
android:clickable="true"
>
<TextView
android:id="#+id/myGroupsLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/myGroups"
android:layout_centerInParent="true"
android:textColor="#bdbdbd"
android:textSize="16dp"
android:textStyle="bold"
/>
<ImageView
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="15dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/ic_search" />
</RelativeLayout>
<View android:layout_height="2dip"
android:layout_width="wrap_content"
android:background="#cccccc"
/>
<ListView android:id="#+id/listview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000000"
android:cacheColorHint="#000000"
/>
<Button
android:id="#+id/buttonCreateGroup"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:background="#layout/button_confirm"
android:layout_gravity="center_horizontal"
android:text="#string/createOneGroup"
android:textColor="#FFFFFF"
android:textSize="22dp"
android:layout_marginTop="15dp"
/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
</LinearLayout>
Does anyone have any tips on how can I keep the footer fixed, scroll down until the end of the list and then show the button? I want that it looks like the button is the last item at the List.
EDIT: Entire XML posted
The ListView and the Button should be in a RelativeLayout and in the Button you should set android:layout_below="#id/listview"
<RelativeLayout
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="#+id/listview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:cacheColorHint="#000000"
android:textColor="#000000" />
<Button
android:layout_below="#id/listview"
android:id="#+id/buttonCreateGroup"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="20dp"
android:layout_marginTop="15dp"
android:background="#layout/button_confirm"
android:text="#string/createOneGroup"
android:textColor="#FFFFFF"
android:textSize="22dp" />
</RelativeLayout>
Try it in the following manner:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout //Header
android:layout_alignParentTop="true">
</RelativeLayout>
<ListView
android:layout_below="#+id/header" />
<RelativeLayout //Button(footer)
android:layout_alignParentBottom="true"
android:layout_below="#+id/listView" >
</RelativeLayout>
</RelativeLayout>
The only way I could achieve the exact requirements I explained above was doing the following:
-In the XML file with the layout of the list items, I added a button with android:visibility="gone".
-In my custom ListView adapter, I always add an empty object in the last position. I simply add an object with a flag that shows it is the last in the list.
-In the method getView() that I override in the custom Adapter, I check if the object in the current position has the flag indicating that it is the last in the list. If so, I set the button visibility to VISIBLE, otherwise I fill the other components.
If anyone is facing the same problem and needs some sample code from my solution just ask here.
Try this:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal" >
<TextView
android:id="#+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginBottom="5dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:text="baseTitle"
android:textColor="#FFFFFF"
android:textSize="18dp"
android:textStyle="bold" />
<Button
android:id="#+id/buttonHelp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_gravity="center_vertical" />
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="fill_vertical"
android:orientation="vertical" >
<LinearLayout
android:id="#+id/buttonBar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:gravity="center"
android:orientation="vertical" >
<RelativeLayout
android:id="#+id/bottomButtomBar"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:orientation="horizontal" >
<Button
android:id="#+id/myGroups"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="15dp"
android:gravity="center"
android:text="myGroups"
android:textColor="#000000"
android:textSize="13dp" />
<Button
android:id="#+id/createGroups"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_gravity="center"
android:gravity="center"
android:text="createGroups"
android:textColor="#000000"
android:textSize="13dp" />
<Button
android:id="#+id/configurations"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="15dp"
android:gravity="center"
android:text="configurations"
android:textColor="#000000"
android:textSize="13dp" >
</Button>
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="#id/buttonBar"
android:orientation="vertical" >
<LinearLayout
android:id="#+id/listContent"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<RelativeLayout
android:id="#+id/searchBarLayout"
android:layout_width="fill_parent"
android:layout_height="48dp"
android:clickable="true"
android:gravity="center_vertical"
android:orientation="horizontal" >
<TextView
android:id="#+id/myGroupsLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="myGroups"
android:textColor="#bdbdbd"
android:textSize="16dp"
android:textStyle="bold" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="15dp" >
</ImageView>
</RelativeLayout>
<ScrollView
android:id="#+id/scroll"
android:layout_width="fill_parent"
android:layout_height="280dip"
android:layout_margin="7dip"
android:scrollbars="none" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >
<ListView
android:id="#+id/listview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:cacheColorHint="#000000"
android:textColor="#000000" />
<Button
android:id="#+id/buttonCreateGroup"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="20dp"
android:layout_marginTop="15dp"
android:text="createOneGroup"
android:textColor="#FFFFFF"
android:textSize="22dp" />
</LinearLayout>
</ScrollView>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
</LinearLayout>
I've a relative layout in android for a chat application.The problem is that the listview on my screen when grows the last elements are hidden behind the textbox and button which I've placed at the bottom.
I am using the following layout file.
<?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:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView android:id="#+id/PreviousChatsButton"
android:padding="5dip"
android:text="#string/ViewPreviousChats"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:focusable="true"
>
</TextView>
<ListView
android:id="#android:id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>
<TextView android:id="#+id/NoChatsMsg"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/NoNewChatMsg"
/>
<Button
android:id="#+id/SubmitButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:text="#string/Submit"
android:onClick="SubmitButtonClick" />
<EditText
android:id="#+id/Chatbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#id/SubmitButton"
android:layout_alignBottom="#id/SubmitButton"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="#id/SubmitButton"
android:ems="10"
android:inputType="text" >
</EditText>
</RelativeLayout>
what you want to do is in the LinearLayout do android:layout_above="#+id/Chatbox" that will make sure it does not go below it
//try this its working fine for me
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:id="#+id/PreviousChatsButton"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:focusable="true"
android:gravity="center_horizontal"
android:padding="5dip"
android:text="ViewPreviousChats" >
</TextView>
<ListView
android:id="#android:id/list"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/NoChatsMsg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="#string/NoNewChatMsg" />
<Button
android:id="#+id/SubmitButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:onClick="SubmitButtonClick"
android:text="#string/Submit" />
<EditText
android:id="#+id/Chatbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#id/SubmitButton"
android:layout_alignBottom="#id/SubmitButton"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="#id/SubmitButton"
android:ems="10"
android:inputType="text" >
</EditText>
</LinearLayout>
</LinearLayout>
Use android:layout_above to avoid this problem :
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<Button
android:id="#+id/SubmitButton" ... />
<LinearLayout
android:layout_above="#id/SubmitButton" ... >
...
</LinearLayout>
Note that you have to declare your button before the LinearLayout for this to work.
I want to implement tabwidget with several tabs, each one of them represents data from single data source which can change dynamicaly, so i cant use several activities, because as far as i understand Activity is more like an application which is not exists while its hidden.
So ive created tabwidget like this:
<ScrollView android:id ="#+id/settings_view"
android:layout_width="match_parent"
android:layout_height="match_parent">
</ScrollView>
<ScrollView android:id="#+id/maps_view"
android:layout_width="match_parent"
android:layout_height="match_parent">
</ScrollView>
<EditText android:id="#+id/statistics_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:singleLine="false"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip">
</EditText>
<RelativeLayout android:id="#+id/about_view"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="#+id/icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:tint="#55ff0000"
android:src="#drawable/main"
android:layout_centerInParent="true"/>
<TextView
android:id="#+id/appname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/app_name"
android:layout_below="#id/icon"
android:layout_centerInParent="true"/>
<TextView
android:id="#+id/version"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/appname"
android:layout_centerInParent="true"/>
<TextView
android:id="#+id/site"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/app_site"
android:layout_below="#id/version"
android:layout_centerInParent="true"/>
<TextView
android:id="#+id/copyright"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/app_copyright"
android:layout_below="#id/site"
android:layout_centerInParent="true"/>
</RelativeLayout>
<RelativeLayout android:id ="#+id/gatewaylist_view"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="10dip"
>
<LinearLayout
android:id="#+id/bottom_view"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true">
<!--Put whatever view item you want here -->
<Button android:text="Add Gateway"
android:id="#+id/BtnToClick"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
</Button>
</LinearLayout>
<ListView
android:id="#+id/android:list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:cacheColorHint="#00000000"
android:layout_above="#id/bottom_view"
/>
</RelativeLayout>
<ScrollView android:id="#+id/gatewayparams_view"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout android:id="#+id/addressLabels"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="4">
<TextView android:id="#+id/lblIP"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:text="#string/hostLabel"
android:layout_weight="3"/>
<TextView android:id="#+id/lblPort"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:text="#string/portLabel"
android:layout_toRightOf="#id/lblIP"
android:layout_alignParentRight="true"
android:layout_weight="1"/>
</LinearLayout>
<LinearLayout android:id="#+id/addressEditBoxes"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="4"
android:layout_below="#id/addressLabels">
<EditText android:id="#+id/edtHost"
android:layout_height="wrap_content"
android:layout_width="0dip"
android:layout_alignParentLeft="true"
android:inputType="text"
android:text="192.168.1.141"
android:layout_weight="3"/>
<EditText android:id="#+id/edtPort"
android:layout_height="wrap_content"
android:layout_width="0dip"
android:inputType="number"
android:text="9988"
android:layout_alignParentRight="true"
android:layout_weight="1"
/>
</LinearLayout>
<CheckBox android:id="#+id/chkUseProxy"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_alignParentLeft="true"
android:text="#string/useProxyLabel"
android:layout_weight="1"
android:layout_below="#id/addressEditBoxes"/>
<LinearLayout android:id="#+id/proxyLables"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="4"
android:layout_below="#id/chkUseProxy">
<TextView android:id="#+id/lblProxyIP"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:text="#string/hostLabel"
android:layout_weight="3"/>
<TextView android:id="#+id/lblProxyPort"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:text="#string/portLabel"
android:layout_toRightOf="#id/lblProxyIP"
android:layout_alignParentRight="true"
android:layout_weight="1"/>
</LinearLayout>
<LinearLayout android:id="#+id/proxyEditBoxes"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="4"
android:layout_below="#id/proxyLables">
<EditText android:id="#+id/edtProxyHost"
android:layout_height="wrap_content"
android:layout_width="0dip"
android:layout_alignParentLeft="true"
android:inputType="text"
android:text="192.168.1.141"
android:layout_weight="3"/>
<EditText android:id="#+id/edtProxyPort"
android:layout_height="wrap_content"
android:layout_width="0dip"
android:inputType="number"
android:text="9988"
android:layout_alignParentRight="true"
android:layout_weight="1"
/>
</LinearLayout>
<LinearLayout android:id="#+id/encryptionLine"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="4"
android:layout_below="#id/proxyEditBoxes">
<TextView android:id="#+id/lblEncryption"
android:text="##string/encryptiontype"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight ="2"/>
<Spinner android:id="#+id/spinnerenctype"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:drawSelectorOnTop="true"
android:prompt="#string/encryptiontype"
android:layout_weight ="2"
/>
</LinearLayout>
<LinearLayout android:id="#+id/usernameLabels"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="4"
android:layout_below="#id/encryptionLine">
<TextView android:id="#+id/txtUName"
android:text="#string/usernameLabel"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight ="2"/>
<TextView android:id="#+id/txtPassword"
android:text="#string/passwordLabel"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight ="2"/>
</LinearLayout>
<LinearLayout android:id="#+id/usernameEditBoxes"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="4"
android:layout_below="#id/usernameLabels">
<EditText android:id="#+id/edtUsername"
android:layout_height="wrap_content"
android:layout_width="0dip"
android:inputType="text"
android:text="devdev"
android:layout_weight="2"
/>
<EditText android:id="#+id/edtPassword"
android:layout_height="wrap_content"
android:layout_width="0dip"
android:inputType="textPassword"
android:text="devdev"
android:layout_weight="2"
/>
</LinearLayout>
<Button android:layout_height="wrap_content"
android:text="#string/connect"
android:id="#+id/btnConnect"
android:layout_width="match_parent"
android:layout_weight="1"
android:layout_below="#id/usernameEditBoxes"/>
</RelativeLayout>
</ScrollView>
<LinearLayout android:id="#+id/videofield_view"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</LinearLayout>>
</FrameLayout>
<TabWidget
android:id="#android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_weight="0"/>
</LinearLayout>
and i initialize my application like this
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Resources res = getResources(); // Resource object to get Drawables
TabHost tabHost = getTabHost(); // The activity TabHost
tabHost.addTab(tabHost.newTabSpec("tab_gatewaylist").setIndicator("",res.getDrawable(R.drawable.ic_tab_favorites)).setContent(R.id.gatewaylist_view));
tabHost.addTab(tabHost.newTabSpec("tab_gatewayparams").setIndicator("",res.getDrawable(R.drawable.ic_tab_gatewayparams)).setContent(R.id.gatewayparams_view));
tabHost.addTab(tabHost.newTabSpec("tab_videofield").setIndicator("",res.getDrawable(R.drawable.ic_tab_videofield)).setContent(R.id.videofield_view));
tabHost.addTab(tabHost.newTabSpec("tab_maps").setIndicator("",res.getDrawable(R.drawable.ic_tab_maps)).setContent(R.id.maps_view));
tabHost.addTab(tabHost.newTabSpec("tab_statistics").setIndicator("",res.getDrawable(R.drawable.ic_tab_statistics)).setContent(R.id.statistics_view));
tabHost.addTab(tabHost.newTabSpec("tab_settings").setIndicator("",res.getDrawable(R.drawable.ic_tab_settings)).setContent(R.id.settings_view));
tabHost.addTab(tabHost.newTabSpec("tab_about").setIndicator("",res.getDrawable(R.drawable.ic_tab_about)).setContent(R.id.about_view));
tabHost.setCurrentTab(0);
its works ok , but i wonder if i can separate definitions fro different tabs into separate xml files.
Ive tried to do this but application crashes while trying to add corresponding tab.
Thanks in advance.
Have you tried using the <include /> element? http://developer.android.com/resources/articles/layout-tricks-reuse.html
this way you can put the single xml definitions in different files and include them in the main one.