XML-problem, how to get a button/edittext to the bottom

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

XML-problem, how to get a button/edittext to the bottom

Postby Timmeah » Fri Mar 13, 2009 12:20 am

Hi, I'm having a problem and I can't seem to figure it out. My edittext won't go to the bottom of my screen.

Whatever I try, it stays in the upperleft. I use the next code, what am I doing wrong???

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <?xml version="1.0" encoding="utf-8"?>
  2.  
  3.  
  4.  
  5. <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
  6.  
  7.    android:layout_width="fill_parent"
  8.  
  9.    android:layout_height="fill_parent">
  10.  
  11.  
  12.  
  13.     <com.example.android.lunarlander.LunarView
  14.  
  15.      android:id="@+id/lunar"
  16.  
  17.      android:layout_width="fill_parent"
  18.  
  19.      android:layout_height="fill_parent"/>
  20.  
  21.    
  22.  
  23.     <RelativeLayout
  24.  
  25.        android:layout_width="fill_parent"
  26.  
  27.        android:layout_height="fill_parent" >
  28.  
  29.    
  30.  
  31.         <TextView
  32.  
  33.          android:id="@+id/text"
  34.  
  35.                   android:text="@string/lunar_layout_text_text"
  36.  
  37.                   android:visibility="visible"
  38.  
  39.          android:layout_width="wrap_content"
  40.  
  41.          android:layout_height="wrap_content"
  42.  
  43.          android:layout_centerInParent="true"
  44.  
  45.          android:gravity="center_horizontal"
  46.  
  47.          android:textColor="#000000"
  48.  
  49.          android:textSize="24sp" android:textStyle="bold"/>
  50.  
  51.  
  52.  
  53. <EditText
  54.  
  55. android:id="@+id/widget29"
  56.  
  57. android:layout_width="193px"
  58.  
  59. android:layout_height="wrap_content"
  60.  
  61. android:text="EditText"
  62.  
  63. android:textSize="18sp"
  64.  
  65. android:layout_x="8px"
  66.  
  67. android:layout_y="373px"
  68.  
  69. />
  70.  
  71.      
  72.  
  73.      </RelativeLayout>
  74.  
  75.      
  76.  
  77. </FrameLayout>
Parsed in 0.004 seconds, using GeSHi 1.0.8.4
Timmeah
Junior Developer
Junior Developer
 
Posts: 14
Joined: Tue Feb 10, 2009 4:30 pm

Top

Postby Timmeah » Fri Mar 13, 2009 1:12 am

Doing a button with layout_gravity poses the same problem, it is still in the upperleft corner.. Am I missing something essential here?


Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <?xml version="1.0" encoding="utf-8"?>
  2.  
  3.  
  4.  
  5. <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
  6.  
  7.    android:layout_width="fill_parent"
  8.  
  9.    android:layout_height="fill_parent">
  10.  
  11.  
  12.  
  13.     <com.example.android.lunarlander.LunarView
  14.  
  15.      android:id="@+id/lunar"
  16.  
  17.      android:layout_width="fill_parent"
  18.  
  19.      android:layout_height="fill_parent"/>
  20.  
  21.    
  22.  
  23.     <RelativeLayout
  24.  
  25.        android:layout_width="fill_parent"
  26.  
  27.        android:layout_height="fill_parent" >
  28.  
  29.    
  30.  
  31.         <TextView
  32.  
  33.          android:id="@+id/text"
  34.  
  35.                   android:text="@string/lunar_layout_text_text"
  36.  
  37.                   android:visibility="visible"
  38.  
  39.          android:layout_width="wrap_content"
  40.  
  41.          android:layout_height="wrap_content"
  42.  
  43.          android:layout_centerInParent="true"
  44.  
  45.          android:gravity="center_horizontal"
  46.  
  47.          android:textColor="#000000"
  48.  
  49.          android:textSize="24sp" android:textStyle="bold"/>
  50.  
  51.  
  52.  
  53.  
  54.  
  55.     <Button android:id="@+id/ok_button"
  56.  
  57.          android:layout_width="wrap_content"
  58.  
  59.            android:layout_height="wrap_content"
  60.  
  61.            android:layout_marginBottom="20dip"        
  62.  
  63.            android:layout_gravity="center_horizontal|bottom"        
  64.  
  65.            android:padding="12dip"
  66.  
  67.            android:text="OK" />
  68.  
  69.  
  70.  
  71.      </RelativeLayout>
  72.  
  73.      
  74.  
  75. </FrameLayout>
Parsed in 0.004 seconds, using GeSHi 1.0.8.4
Timmeah
Junior Developer
Junior Developer
 
Posts: 14
Joined: Tue Feb 10, 2009 4:30 pm

Postby MrSnowflake » Fri Mar 13, 2009 10:35 am

Did you check the documentation for relativelayout? It allows you to position views relative to each other.
User avatar
MrSnowflake
Moderator
Moderator
 
Posts: 1439
Joined: Sat Feb 16, 2008 3:11 pm
Location: Flanders, Belgium

Postby Timmeah » Fri Mar 13, 2009 1:19 pm

MrSnowflake wrote:Did you check the documentation for relativelayout? It allows you to position views relative to each other.


Ok, thanks it works, had to put the code above the relative lay-out.

However, my button is not shown completely.. how is this possible??

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <?xml version="1.0" encoding="utf-8"?>
  2.  
  3.  
  4.  
  5. <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
  6.  
  7.    android:layout_width="fill_parent"
  8.  
  9.    android:layout_height="fill_parent">
  10.  
  11.  
  12.  
  13.  
  14.  
  15.     <com.example.android.lunarlander.LunarView
  16.  
  17.      android:id="@+id/lunar"
  18.  
  19.      android:layout_width="fill_parent"
  20.  
  21.      android:layout_height="fill_parent"
  22.  
  23.  
  24.  
  25.      />
  26.  
  27.      
  28.  
  29.        <EditText
  30.  
  31. android:id="@+id/containerid"
  32.  
  33. android:layout_width="185sp"
  34.  
  35. android:layout_height="35sp"
  36.  
  37.  
  38.  
  39. android:textSize="12sp"
  40.  
  41. android:textStyle="bold"
  42.  
  43. android:layout_gravity="bottom|left"
  44.  
  45. android:layout_marginLeft="5sp"
  46.  
  47. android:hint="Text input ..."/>  
  48.  
  49.  
  50.  
  51.      
  52.  
  53.     <Button android:id="@+id/versturen"
  54.  
  55.                 android:layout_width="wrap_content"
  56.  
  57.            android:layout_height="35sp"
  58.  
  59.            android:text="Send"
  60.  
  61.            android:textSize="12sp"
  62.  
  63.            android:textStyle="bold"
  64.  
  65.            android:layout_gravity="bottom|left"
  66.  
  67.                 android:layout_marginLeft="193sp"/>
  68.  
  69.          
  70.  
  71.  
  72.  
  73.     <RelativeLayout
  74.  
  75.        android:layout_width="fill_parent"
  76.  
  77.        android:layout_height="fill_parent" >
  78.  
  79.    
  80.  
  81.  
  82.  
  83.         <TextView
  84.  
  85.          android:id="@+id/text"
  86.  
  87.                   android:text="@string/lunar_layout_text_text"
  88.  
  89. android:visibility="visible"
  90.  
  91.          android:layout_width="wrap_content"
  92.  
  93.          android:layout_height="wrap_content"
  94.  
  95.          android:layout_centerInParent="true"
  96.  
  97.          android:gravity="center_horizontal"
  98.  
  99.          android:textColor="#000000"
  100.  
  101.          android:textSize="24sp" android:textStyle="bold"/>
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.      </RelativeLayout>
  110.  
  111.      
  112.  
  113. </FrameLayout>
Parsed in 0.005 seconds, using GeSHi 1.0.8.4
Attachments
and.jpg
and.jpg (3.12 KiB) Viewed 172 times
Timmeah
Junior Developer
Junior Developer
 
Posts: 14
Joined: Tue Feb 10, 2009 4:30 pm

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 5 guests