XML-Layouting: RelativeLayout lässt sich nicht anordnen

F

fugu2.0

Neues Mitglied
3
Heyho ihrs!

Ich habe ein Problem beim Layouten in XML. Und zwar lässt sich das RelativeLayout mit der id "additional_product_infos" nicht unterhalb der "order_buttons" anordnen. Aus irgendeinem Grund wird dieser Teil direkt oben in der ScrollView platziert. Lass ich das umkapselnde Layout bei den Buttons weg und setze dann im additional_product_infos layout_below="@id/direct_order" wird alles korrekt dargestellt. Allerdings will ich die Buttons auf einem gemeinsamen, farblich vom Rest abgehobenen Hintergrund haben. Hier mein XML-Code (die background-Elemente dienen nur zur unterscheidung der einzelnen Komponenten):

Code:
<?xml version="1.0" encoding="utf-8"?>
<!--Ur-Layout mit Header und ScrollView -->
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
      android:layout_height="fill_parent">
      
      <TextView
         android:id="@+id/header"
           android:layout_width="fill_parent"
         android:layout_height="wrap_content"
         android:background="@drawable/frontpage_footer_bg"/>
         
     <!-- ScrollView beinhaltet alles, was später über den Screen scrollen soll -->
      <ScrollView
           android:id="@+id/scroll_content"
           android:layout_width="fill_parent"
           android:layout_height="fill_parent"
           android:background="@layout/background"
           android:layout_below="@id/header"> 
   
           <!-- Kapselndes RelativeLayout für den Inhalt der ScrollView. 
                ScrollView kann nur ein Layout als Child beinhalten! -->
        <RelativeLayout
               android:layout_gravity="fill"
               android:layout_width="fill_parent"
               android:layout_height="wrap_content"
            android:layout_margin="10dip"
               android:background="#00FF00">
               
               <TextView
                android:id="@+id/title_manufacturer"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:textColor="#ffffff"
                android:textStyle="bold"
                android:background="#ff0000"
                android:text="iMac 27''\nAPPLE"/>
                
               <ImageView
                   android:layout_below="@id/title_manufacturer"
                android:background="#0000ff"
                android:id="@+id/product_picture"
                android:maxWidth="150dip"
                android:maxHeight="150dip"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@drawable/icon150x150"/>
            
            <!-- RelativeLayout für TextViews, die rechts neben dem Produkt-
                 bild angezeigt werden sollen (Preis, Versandkosten, Versanddetails  -->
            <RelativeLayout
                android:id="@+id/price_and_shipping_info"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_toRightOf="@id/product_picture"
                android:layout_below="@id/title_manufacturer"
                android:layout_marginLeft="10dip"
                android:layout_marginTop="10dip"
                android:background="#772288">
                    
                   <TextView
                    android:background="#558800"
                    android:id="@+id/price"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                       android:layout_below="@id/title_manufacturer"
                    android:text="@string/price"/>
                    
                   <TextView
                    android:background="#996633"
                    android:id="@+id/product_price"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_below="@id/price"
                    android:text="997,56€"/>
                    
                   <TextView
                    android:background="#0aa0aa"
                    android:id="@+id/shipping_costs"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_below="@id/product_price"
                    android:text="@string/shipping_costs"/>
                    
                   <TextView
                    android:background="#336699"
                    android:id="@+id/shipping"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_below="@id/shipping_costs"
                    android:text="5,99€"/>
                    
                   <TextView
                    android:background="#abcde0"
                    android:id="@+id/shipping_details"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_below="@id/shipping"
                    android:textColor="#000000"
                    android:text="Versandbereit innerhalb der nächsten vierundzwanzig Stunden"/>
            </RelativeLayout>
            
             
            <!-- LinearLayout für die Buttons, die unter dem Produktbild angezeigt werden sollen --> 
            <LinearLayout
                androidid="@+id/order_buttons"
                android:orientation="horizontal"
                android:gravity="center"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="30dip"
                android:layout_below="@id/price_and_shipping_info"
                android:background="#ffff00">
            
                <Button
                    android:id="@+id/add_to_cart"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:text="@string/add_to_cart"/>
                
                <Button
                    android:id="@+id/direct_order"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:text="@string/direct_order"/>

            </LinearLayout>
            
            <!-- RelativeLayout das die zusätzlichen Produktinformationen darstellen soll.
                 Problem: wird trotz android:layout_below="@id/order_buttons" nicht unter 
                 den Buttons angezeigt -->        
            <RelativeLayout
                android:id="@+id/additional_product_informations"
                android:layout_below="@id/direct_order"
                   android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:background="#c9c9c9">
                
                <TextView
                    android:id="@+id/information_header"
                    android:gravity="center"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:text="@string/product_information_header"
                    android:textColor="#000000"/>
                <View
                    android:id="@+id/separator"
                    android:layout_below="@id/information_header"
                    android:layout_width="fill_parent"
                    android:layout_height="2dip"
                    android:background="#000000"/>
                
                <TextView
                    android:id="@+id/ean"
                    android:layout_below="@id/separator"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:text="@string/ean"
                    android:textColor="#000000"/>
                
                <View
                    android:id="@+id/small_separator1"
                    android:layout_below="@id/ean"
                    android:layout_width="fill_parent"
                    android:layout_height="2dip"
                    android:layout_marginLeft="10dip"
                    android:layout_marginRight="10dip"
                    android:background="#d7d7d7"/>
                                    
                <TextView
                    android:id="@+id/order_number"
                    android:layout_below="@id/small_separator1"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:text="@string/order_number"
                    android:textColor="#000000"/>
                    
                <View
                    android:id="@+id/small_separator2"
                    android:layout_below="@id/order_number"
                    android:layout_width="fill_parent"
                    android:layout_height="2dip"
                    android:layout_marginLeft="10dip"
                    android:layout_marginRight="10dip"
                    android:background="#d7d7d7"/>
                    
                <TextView
                    android:id="@+id/manufacturer"
                    android:layout_below="@id/small_separator2"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:text="@string/manufacturer"
                    android:textColor="#000000"/>
                    
                <View
                    android:id="@+id/small_separator3"
                    android:layout_below="@id/manufacturer"
                    android:layout_width="fill_parent"
                    android:layout_height="2dip"
                    android:layout_marginLeft="10dip"
                    android:layout_marginRight="10dip"
                    android:background="#d7d7d7"/>
                    
                <TextView
                    android:id="@+id/product_description"
                    android:layout_below="@id/small_separator3"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:text="@string/product_description"
                    android:textColor="#000000"/>
            </RelativeLayout>    
        </RelativeLayout>
      </ScrollView>
</RelativeLayout>

Gibt es einen logischen Grund, warum ich das RelativeLayout nicht unter dem Linear Layout anordnen kann? (Änder ich das Linear in ein RelativeLayout, komme ich übrigens zum gleichen Ergebnis)
 

Ähnliche Themen

SaniMatthias
Antworten
19
Aufrufe
1.000
swa00
swa00
M
Antworten
3
Aufrufe
211
moin
M
SpeedySix
Antworten
13
Aufrufe
1.410
jogimuc
J
Zurück
Oben Unten