2016-12-27 20 views
1

我有这个布局2个TextViews不同的“优先级”

<LinearLayout 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     android:orientation="horizontal" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 
    <TextView 
      android:id="@+id/text1" 
      android:layout_width="fill_parent" 
      android:layout_height="match_parent" 
      android:ellipsize="end" /> 

    <TextView 
      android:id="@+id/text2" 
      android:layout_width="wrap_content" 
      android:layout_height="match_parent" 
      android:gravity="right" 
      android:maxLines="1" /> 
</LinearLayout> 

但我想text2的有“较高优先级”,比文本1

含义的情况下,屏幕不适合这两个我需要有这种行为:

文本2必须始终除非它是屏幕的80%以上,在这种情况下使用完全显示在一行“...”

Text1使用Text2留下的任何空间,可以使用多行,如果不适合,应该在末尾使用“...”

这是LinearLayout的可能性,或者我应该使用不同的容器呢?

+0

我不知道是否有可能与Android提供任何布局。你可能必须编写自定义视图或以编程方式进行管理...... – xFighter

+0

您是否尝试过使用'layout_weight'? – yogur

+0

@xFighter我只喜欢xml –

回答