Textview溢出

时间:2012-04-07 12:06:14

标签: android android-layout android-ui

我有一个布局,左边是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>

1 个答案:

答案 0 :(得分: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