【问题标题】:issue in layout android布局android中的问题
【发布时间】:2017-01-15 06:58:55
【问题描述】:

我试图在 LinearLayout 中显示两个文本视图。但是一个显示有点大,一个显示有点小......如果我保持两个文本视图字体大小与它显示的一样好,但是如果我让第二个文本视图字体大小变小,那么视图也会变小。图片如下所示

我的 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>

【问题讨论】:

  • image 用于所需设计?
  • @ρяσѕρєяK 图像显示问题...我需要两个行高相同...在图像中您可以看到第二个视图的日期高度比第一个视图小
  • 那么,你想要在你的布局中做什么?你想在你的线性布局中让两个文本视图的宽度相等吗?
  • @DharmaKshetri 我希望两个文本视图高度相同....您可以看到第二个视图的高度很小

标签: android xml android-layout listview


【解决方案1】:

尝试将背景图片放在 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" >

【讨论】:

  • 您刚刚对一个带有自定义原因的问题进行了近距离投票,说明“这是垃圾邮件”。这有危险信号,请使用这些信号来实际删除帖子并提醒版主销毁帐户,而不是将垃圾邮件留在网站上,直到有人过来实际删除帖子+用户。
猜你喜欢
  • 2011-06-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-02-22
  • 1970-01-01
  • 2010-12-04
相关资源
最近更新 更多