2017-01-15 204 views
0

我想在LinearLayout中显示两个文本视图。但一个是显示小大,一个是小...如果我保持两个文字视图的字体大小相同比显示良好,但如果我让第二个文字视图字体大小小,然后查看也越来越小。形象就像下面问题布局android

enter image description here

和我的XML是像下面。我错过了什么?

<?xml version="1.0" encoding="utf-8"?> 
 
<LinearLayout 
 
    xmlns:android="http://schemas.android.com/apk/res/android" 
 
    android:layout_width="match_parent" 
 
    android:layout_height="match_parent" 
 
    android:weightSum="1" 
 
    android:orientation="horizontal" > 
 

 
    <TextView 
 
     android:id="@+id/tv_listtitle" 
 
     android:layout_width="fill_parent" 
 
     android:layout_height="wrap_content" 
 
     android:padding="15dp" 
 
     android:layout_weight="0.3" 
 
     android:gravity="left" 
 
     android:text="Hello" 
 
     android:maxLines="1" 
 
     android:ellipsize="end" 
 
     android:background="@color/light_grey" 
 
     android:layout_marginLeft="5dp" 
 
     android:layout_marginStart="5dp" 
 
     android:textSize="16sp" 
 
     android:textStyle="bold"/> 
 

 
    <TextView 
 
     android:id="@+id/tv_date" 
 
     android:layout_width="fill_parent" 
 
     android:layout_height="wrap_content" 
 
     android:padding="15dp" 
 
     android:text="15/12/2016" 
 
     android:gravity="left" 
 
     android:maxLines="1" 
 
     android:ellipsize="end" 
 
     android:background="@color/light_grey" 
 
     android:textSize="12sp" 
 
     android:textStyle="bold"/> 
 

 
</LinearLayout>

+0

'image'是需要设计? –

+0

@ρяσѕρєяK图像显示问题...我需要两个行高一样...在图像中你可以看到第二个视图与日期有一点小高度,然后第一个 –

+0

所以,你想在你的布局?你想在你的线性布局中使用两个textview相等的宽度吗? –

回答

0

尝试把背景图像在LinearLayout中,而不是

<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:weightSum="1" 
    android:background="@color/light_grey"   
    android:orientation="horizontal" > 
+2

你刚刚用一个自定义的原因表明“这是垃圾邮件”投了一个问题。这里有红旗,请使用它们来实际删除帖子,并提醒版主销毁帐户,而不是让垃圾邮件停留在网站上,直到有人来实际删除post +用户。 – Adriaan