<LinearLayout
android:layout_width = "wrap_content"
android:layout_height = "wrap_content"
android:orientation = "horizontal" >
<TextView
android:id="@+id/txt_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_gravity="center_vertical"
android:layout_weight = "1"
android:ellipsize = "end"
android:singleLine="true"
android:text="13535669090"
android:textColor="#323232"
android:textSize="16sp"/>
<TextView
android:id="@+id/txt_medal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="5sp"
android:background="@color/app_main_bg_color"
android:text="金牌经纪"
android:maxLines="1"
android:textColor="#fff"
android:textSize="13sp"/>
</LinearLayout>
如你所见我在第一个TextView 中 使用了layout_weight,而第二个却没有,默认weight为0。那么现在的情况你可以理解为第二个TextView全部显示,第一个TextView 在 剩余空间 按比例显示