【问题标题】:Make Listview (item has weight property) Horizontally scrollable使 Listview(项目具有权重属性)水平滚动
【发布时间】:2019-04-03 06:41:31
【问题描述】:

Horizontal Scrollview 可用于 listview 使其两侧滚动。

但我的列表视图项目是:

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal" android:layout_width="match_parent"
    android:layout_height="wrap_content">
    <TextView
        android:layout_width="0dp"
        android:layout_weight="1"
        android:layout_height="match_parent"
        android:id="@+id/textView87" />
     <TextView
        android:layout_width="0dp"
        android:layout_weight="1"
        android:layout_height="match_parent"
        android:id="@+id/textView88" />
     <TextView
        android:layout_width="0dp"
        android:layout_weight="1"
        android:layout_height="match_parent"
        android:id="@+id/textView89" />
     <TextView
        android:layout_width="0dp"
        android:layout_weight="1"
        android:layout_height="match_parent"
        android:id="@+id/textView90" />

</LinearLayout>

我想要什么:考虑第一个文本视图。在所有行中,我需要相同的 textview 宽度。 (所有文本视图都相同)

有没有办法做到这一点。请帮帮我!!!

【问题讨论】:

  • 你能解释清楚吗?使其在我的设备中完美运行。
  • @Ashish 每行有 4 个文本视图。如果文本很长,我需要水平滚动它。但在所有行中,该 textview 宽度应该相同。请检查不同长度的文本。 (它应该看起来像一个电子表格)
  • @JyotiJK 查看我的更新答案

标签: android listview android-linearlayout


【解决方案1】:

试试这个

<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal" android:layout_width="match_parent"
android:weightSum="4"
android:layout_height="wrap_content">
<TextView
    android:layout_width="0dp"
    android:layout_weight="1"
    android:layout_height="match_parent"
    android:id="@+id/textView87" />
 <TextView
    android:layout_width="0dp"
    android:layout_weight="1"
    android:layout_height="match_parent"
    android:id="@+id/textView88" />
 <TextView
    android:layout_width="0dp"
    android:layout_weight="1"
    android:layout_height="match_parent"
    android:id="@+id/textView89" />
 <TextView
    android:layout_width="0dp"
    android:layout_weight="1"
    android:layout_height="match_parent"
    android:id="@+id/textView90" />

【讨论】:

    猜你喜欢
    • 2010-09-26
    • 2015-12-29
    • 2016-02-19
    • 2021-05-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-11-05
    相关资源
    最近更新 更多