0

我有一个布局,左边有 ImageView,右边有 TextView:

<ImageView
        android:src="@drawable/alert"
        android:id="@+id/articleStoryImage" 
        android:layout_below="@+id/articleStorySubTitle"        
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="10sp"
         />
<TextView 
   android:id="@+id/articleStory"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:layout_below="@+id/articleStorySubTitle"
   android:layout_toRightOf="@+id/articleStoryImage"
   android:gravity="right"                  
   android:inputType="textMultiLine"        
   android:text="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
   aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
   aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
   android:ellipsize="end"
   android:layout_marginTop="10sp"
   android:textSize="11sp"
   android:textColor="#000000" />

我想要做的是,TextView 文本将从 ImageView 的右侧开始,但会在 ImageView 下方继续。你可以称之为某种溢出。

我怎样才能做到这一点?

谢谢。

编辑:完整的 XML:

    <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#FFFFFF"
     android:orientation="horizontal" >
    <TextView 
       android:id="@+id/articleStoryTitle"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"               
       android:text="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbbbbbb"
       android:typeface="sans"
       android:gravity="right"
       android:ellipsize="end"
       android:singleLine="false"   
       android:inputType="textMultiLine"             
       android:textSize="25sp"  
       android:textColor="#DBA118"
       android:textStyle="bold" />
    <TextView 
       android:id="@+id/articleStorySubTitle"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:layout_below="@+id/articleStoryTitle"
       android:gravity="right"                  
       android:inputType="textMultiLine"        
       android:text="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbbbbbb"
       android:ellipsize="end"
       android:layout_marginTop="10sp"
       android:textSize="12sp"
       android:textColor="#000000"   
       android:textStyle="bold" />
    <ImageView
            android:src="@drawable/alert"
            android:id="@+id/articleStoryImage" 
            android:layout_below="@+id/articleStorySubTitle"        
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="10sp"
             />
    <TextView 
       android:id="@+id/articleStory"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:layout_below="@+id/articleStorySubTitle"
       android:layout_toRightOf="@+id/articleStoryImage"
       android:gravity="right"                  
       android:inputType="textMultiLine"        
       android:text="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
       aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
       aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
       android:ellipsize="end"
       android:layout_marginTop="10sp"
       android:textSize="11sp"
       android:textColor="#000000" />
</RelativeLayout>
4

1 回答 1

0

我知道你可能会得到更好的解决方案,但你可以检查一下:

<?xml version="1.0" encoding="utf-8"?>  
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"   
    android:id="@+id/RelativeLayout01"  
    android:layout_width="fill_parent"  
    android:layout_height="wrap_content" >  
 <TextView  
    android:id="@+id/tv"   
    android:layout_width="200dp"  
    android:layout_height="150dp"  
    android:layout_alignBottom="@+id/ImageView011"   
    android:layout_marginTop="22dp"  
    android:text="hi every body hi every body hi everybodyend"                        
    android:textSize="20dp" />   
 <ImageView  
    android:id="@+id/ImageView011"   
    android:layout_width="100dp"   
    android:layout_height="100dp"   
    android:layout_alignParentLeft="true"   
    android:layout_marginTop="22dp" 
    android:layout_marginLeft="22dp"  
    android:background="@drawable/imag" />
 <TextView  
    android:id="@+id/textView1" 
    android:layout_width="wrap_content"  
    android:layout_height="350dp"   
    android:layout_alignParentBottom="true"    
    android:text=" TextView TextView TextView TextView TextView"                  
    android:textSize="20dp" />
  </RelativeLayout>

还要检查这个链接:http ://dev.androidteam.ru/snippets/textview/leadingmarginspan2

于 2012-04-07T12:58:20.287 回答