1

我正在努力实现以下目标:

在此处输入图像描述

我正在尝试LinearLayoutRelativLayout.

我已经尝试将其包装RelativeLayout成 a LinearLayout,但这没有任何区别。我正在使用RelativeLayout来在图像缩略图前面显示文本。

但是,我仍然无法弄清楚,我尝试了一切。

这里是 XML:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:adjustViewBounds="true"      
    android:gravity="left|center"
    android:layout_weight="1"  
    android:orientation="vertical"
    android:background="#313131" >     
    <LinearLayout
        android:layout_width="fill_parent"              
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:gravity="left" >       
        <ImageView
            android:id="@+id/otv2"         
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp"         
            android:layout_marginRight="10dp"
            android:layout_marginTop="5dp"
            android:layout_marginBottom="5dp"          
            android:src="@drawable/otv_2"          
            android:gravity="left" />
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"         
            android:layout_marginRight="10dp"
            android:layout_marginTop="5dp"  
            android:layout_weight="1"       
            android:text="sehen was bewegt" 
            android:textColor="#FFFFFF"       
            android:textAppearance="?android:attr/textAppearanceSmall"
            android:gravity="right" />
    </LinearLayout>    
    <View android:layout_width="fill_parent"
        android:layout_height="1dp"
        android:background="#007cc2"/> 
    <LinearLayout      
        android:layout_width="fill_parent"             
        android:layout_height="wrap_content"
        android:layout_marginBottom="25dip"
        android:orientation="vertical"  
        android:adjustViewBounds="true"  
        android:gravity="left|top" >     
        <RelativeLayout             
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"                 
            android:layout_gravity="left" >           
            <ImageView
                android:id="@+id/otv2_thumb"    
                android:adjustViewBounds="true"       
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="10dp"         
                android:layout_marginRight="10dp"
                android:layout_marginTop="10dp"                
                android:layout_marginBottom="3dp" />

            <TextView android:id="@+id/duration"
                android:layout_width="fill_parent"  
                android:layout_height="wrap_content" 
                android:textColor="#ffffff" 
                android:layout_alignLeft="@+id/otv2_thumb"
                android:layout_alignTop="@+id/otv2_thumb"
                android:layout_alignRight="@+id/otv2_thumb"
                android:layout_alignBottom="@+id/otv2_thumb"    
                android:layout_marginLeft="10dp"        
                android:text="00:45"
                android:textStyle="bold"
                android:gravity="left|bottom"                          
                android:textAppearance="?android:attr/textAppearanceMedium" />      
        </RelativeLayout>      
        <LinearLayout       
            android:orientation="vertical"
            android:layout_width="wrap_content"        
            android:layout_height="wrap_content"
            android:layout_weight="1"                 
            android:layout_marginTop="10dp"              
            android:background="#666666"
            android:gravity="right|top">       
            <TextView android:id="@+id/location"
                android:layout_width="fill_parent"   
                android:textColor="#3E3F41" 
                android:paddingLeft="0dp"                    
                android:layout_height="fill_parent"
                android:text="EICHENZELL - 03.03.1303"     
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:gravity="left|top"/>            
            <TextView 
                android:id="@+id/text"       
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:paddingLeft="0dp"                     
                android:textColor="#FFFFFF"
                android:text="asdaf asgsadg gadg "     
                android:textAppearance="?android:attr/textAppearanceSmall" 
                android:gravity="left|center" />    
        </LinearLayout>
    </LinearLayout>   
</LinearLayout>

我怎样才能解决这个问题?

4

1 回答 1

3

尝试将android:orientation="vertical"相对和线性布局的父 LinearLayout 更改为水平。像这样:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:adjustViewBounds="true"      
    android:gravity="left|center"
    android:layout_weight="1"  
    android:orientation="vertical"
    android:background="#313131" >     
    <LinearLayout
        android:layout_width="fill_parent"              
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:gravity="left" >       
        <ImageView
            android:id="@+id/otv2"         
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp"         
            android:layout_marginRight="10dp"
            android:layout_marginTop="5dp"
            android:layout_marginBottom="5dp"          
            android:src="@drawable/otv_2"          
            android:gravity="left" />
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"         
            android:layout_marginRight="10dp"
            android:layout_marginTop="5dp"  
            android:layout_weight="1"       
            android:text="sehen was bewegt" 
            android:textColor="#FFFFFF"       
            android:textAppearance="?android:attr/textAppearanceSmall"
            android:gravity="right" />
    </LinearLayout>    
    <View android:layout_width="fill_parent"
        android:layout_height="1dp"
        android:background="#007cc2"/> 
    <LinearLayout      
        android:layout_width="fill_parent"             
        android:layout_height="wrap_content"
        android:layout_marginBottom="25dip"
        android:orientation="horizontal"  
        android:adjustViewBounds="true"  
        android:gravity="left|top" >     
        <RelativeLayout             
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"                 
            android:layout_gravity="left" >           
            <ImageView
                android:id="@+id/otv2_thumb"    
                android:adjustViewBounds="true"       
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="10dp"         
                android:layout_marginRight="10dp"
                android:layout_marginTop="10dp"                
                android:layout_marginBottom="3dp" />

            <TextView android:id="@+id/duration"
                android:layout_width="fill_parent"  
                android:layout_height="wrap_content" 
                android:textColor="#ffffff" 
                android:layout_alignLeft="@+id/otv2_thumb"
                android:layout_alignTop="@+id/otv2_thumb"
                android:layout_alignRight="@+id/otv2_thumb"
                android:layout_alignBottom="@+id/otv2_thumb"    
                android:layout_marginLeft="10dp"        
                android:text="00:45"
                android:textStyle="bold"
                android:gravity="left|bottom"                          
                android:textAppearance="?android:attr/textAppearanceMedium" />      
        </RelativeLayout>      
        <LinearLayout       
            android:orientation="vertical"
            android:layout_width="wrap_content"        
            android:layout_height="wrap_content"
            android:layout_weight="1"                 
            android:layout_marginTop="10dp"              
            android:background="#666666"
            android:gravity="right|top">       
            <TextView android:id="@+id/location"
                android:layout_width="fill_parent"   
                android:textColor="#3E3F41" 
                android:paddingLeft="0dp"                    
                android:layout_height="fill_parent"
                android:text="EICHENZELL - 03.03.1303"     
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:gravity="left|top"/>            
            <TextView 
                android:id="@+id/text"       
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:paddingLeft="0dp"                     
                android:textColor="#FFFFFF"
                android:text="asdaf asgsadg gadg "     
                android:textAppearance="?android:attr/textAppearanceSmall" 
                android:gravity="left|center" />    
        </LinearLayout>
    </LinearLayout>   
</LinearLayout>
于 2013-03-21T15:16:08.100 回答