RelativeLayout not getting proper height

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

RelativeLayout not getting proper height

Postby sandis84 » Thu Dec 10, 2009 2:42 pm

So this is my layout, simplified as much as possible and still containing the error:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. <?xml version="1.0" encoding="utf-8"?>
  2.  
  3. <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  4.  
  5.         android:orientation="horizontal"
  6.  
  7.         android:layout_width="fill_parent"
  8.  
  9.         android:layout_height="120dp"
  10.  
  11.         >
  12.  
  13.         <TextView
  14.  
  15.                 android:id="@+id/home_tab_list_item_text1"
  16.  
  17.                 android:layout_width="200dp"
  18.  
  19.                 android:layout_height="wrap_content"
  20.  
  21.                 android:layout_marginLeft="10dp"
  22.  
  23.                 android:layout_marginTop="8dp"
  24.  
  25.                 android:textSize="15dp"
  26.  
  27.                 android:textColor="#ff000000"
  28.  
  29.                 android:layout_marginBottom="50dp"/>
  30.  
  31. </RelativeLayout>
Parsed in 0.033 seconds, using GeSHi 1.0.8.4


Even thought I both give the layout 120dp in height and give the textview a bottom margin of 50dp, the layout still ends up just wrapping the textview, giving a total height of about 20dp. What is wrong? I know that I could for example add a framelayout to force a certain size, but that is ugly and another view for the device to keep in memory. Why are the views behaving this way?

Cheers,
Per Sandström
sandis84
Experienced Developer
Experienced Developer
 
Posts: 78
Joined: Fri Aug 07, 2009 3:54 pm

Top

Postby qlimax » Thu Dec 10, 2009 8:48 pm

hi master :)


Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1.  
  2. <?xml version="1.0" encoding="utf-8"?>
  3.  
  4. <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  5.  
  6.     android:orientation="horizontal"
  7.  
  8.     android:layout_width="fill_parent"
  9.  
  10.     android:layout_height="120dp"
  11.  
  12.     android:gravity="bottom"
  13.  
  14.     android:background="#552277"
  15.  
  16.     >
  17.  
  18.      <TextView
  19.  
  20.          android:id="@+id/home_tab_list_item_text1"
  21.  
  22.          android:text="sometext"
  23.  
  24.          android:layout_width="200dp"
  25.  
  26.          android:layout_height="wrap_content"
  27.  
  28.          android:layout_marginLeft="10dp"
  29.  
  30.          android:layout_marginTop="8dp"
  31.  
  32.          android:textSize="15dp"
  33.  
  34.          android:textColor="#ffffff"        
  35.  
  36.          android:layout_marginBottom="40dp"
  37.  
  38.          />
  39.  
  40. </RelativeLayout>
Parsed in 0.004 seconds, using GeSHi 1.0.8.4


this layout produces the image in the attachement
but I'm not sure it's what you want...

bye ;)
Attachments
Immagine.png
Immagine.png (2.43 KiB) Viewed 141 times
¯`·.¸¸.><((((º>¯`·.¸¸. ><((((º>
User avatar
qlimax
Master Developer
Master Developer
 
Posts: 271
Joined: Mon Aug 31, 2009 10:54 am
Location: Swiss

Postby sandis84 » Fri Dec 11, 2009 10:14 am

Hello young padawan.

I am getting more and more confused by this problem. If I create an activity that directly loads my xml, it works fine. But in the instance that it does not work, I add the layout within another complex layout. It is contained both inside a scrollview and a linearlayout. However, I cant see why it should create this problem for me.
sandis84
Experienced Developer
Experienced Developer
 
Posts: 78
Joined: Fri Aug 07, 2009 3:54 pm

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 7 guests