【问题标题】:How do I have my layout for the following我如何为以下内容设置布局
【发布时间】:2014-09-15 03:16:52
【问题描述】:

我有一份物品清单。左边的大盒子是我的形象。这两个框是文本框。我希望上面的文本框是椭圆的。这是我当前的布局文件。

主布局

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="5dp" >

<ListView
    android:id="@+id/List"
    android:layout_width="fill_parent"
    android:clickable="true"
    android:layout_height="wrap_content" >
</ListView>

</LinearLayout>

每个列表项内的布局是

<?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="wrap_content"
android:padding="5dp" >

<ImageView
    android:id="@+id/Logo"
    android:layout_width="50dp"
    android:layout_height="50dp"
    android:layout_marginLeft="5dp"
    android:layout_marginRight="20dp"
    android:layout_marginTop="5dp"
    android:src="@drawable/ic_launcher" >
</ImageView>
<LinearLayout android:id="@+id/textViews"
    android:layout_height="match_parent"
    android:layout_width="wrap_content"
    android:clickable="false"
    android:focusableInTouchMode="false"
    android:orientation="vertical">

    <TextView
    android:id="@+id/detail"
    android:layout_width="match_parent"
    android:ellipsize="end"
    android:clickable="false"
    android:focusableInTouchMode="false"
    android:layout_height="wrap_content"
    android:textSize="20sp" >
</TextView>

<TextView
    android:id="@+id/detail2"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:clickable="false"
    android:focusableInTouchMode="false"
    android:textSize="12sp" >
</TextView>

</LinearLayout>

</LinearLayout>

这样的话,如果我在上框的细节太大,在...之前需要两行,下面的textView永远不会显示。

如果上框的文字很小,那么它看起来很好。如何限制上框溢出到整个列表元素大小?

谢谢

【问题讨论】:

    标签: android android-layout android-linearlayout


    【解决方案1】:

    我想你想在上面的框中添加android:singleLine="true"

    【讨论】:

      【解决方案2】:

      你可以给它们一个权重并将高度设置为 match_parent。

          <TextView
              android:id="@+id/detail"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:clickable="false"
              android:ellipsize="end"
              android:layout_weight="1"
              android:focusableInTouchMode="false"
              android:textSize="20sp" >
      
          </TextView>
      
          <TextView
              android:id="@+id/detail2"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:clickable="false"
              android:layout_weight="1"
              android:focusableInTouchMode="false"
              android:textSize="12sp" >
          </TextView>
      

      【讨论】:

        猜你喜欢
        • 2019-03-08
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-07-27
        • 1970-01-01
        • 2013-07-26
        • 2021-04-16
        • 1970-01-01
        相关资源
        最近更新 更多