Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/203.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何强制TableRow中的视图扩展到比表中其他项更宽的范围?_Android_Android Tablelayout - Fatal编程技术网

Android 如何强制TableRow中的视图扩展到比表中其他项更宽的范围?

Android 如何强制TableRow中的视图扩展到比表中其他项更宽的范围?,android,android-tablelayout,Android,Android Tablelayout,我有一个2列的TableLayout,填充了一个片段的整个宽度,但我希望自定义进度条中的某个特定项目是贪婪的,并且占据尽可能多的宽度,直到表格本身的宽度,如下所示: _______________________________ |Text1-1|Value1-2 | | |Text2-1|Value2-2 | | |Text3-1|Value3-2=============| 问题是,与为表保留的区域相比,其他行相当短,我无法使进度条超出其指定列的最宽

我有一个2列的TableLayout,填充了一个片段的整个宽度,但我希望自定义进度条中的某个特定项目是贪婪的,并且占据尽可能多的宽度,直到表格本身的宽度,如下所示:

_______________________________
|Text1-1|Value1-2 |           |
|Text2-1|Value2-2 |           |
|Text3-1|Value3-2=============|
问题是,与为表保留的区域相比,其他行相当短,我无法使进度条超出其指定列的最宽点

首先,我尝试将进度条及其关联的文本视图放置在跨度为2的线性布局中:

<TableRow>
  <TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Text 3-1" />

  <LinearLayout
    android:layout_span="2"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">

    <TextView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="Value3-2" />

    <ProgressBar
      style="?android:attr/progressBarStyleHorizontal"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:max="100" />
  </LinearLayout>
</TableRow>
然后,我删除了LinearLayout,使进度条成为其TableRow的第三个子项:

<TableRow>
  <TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Text 3-1" />

  <TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Value3-2" />

  <ProgressBar
    style="?android:attr/progressBarStyleHorizontal"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:max="100" />
</TableRow>

我如何告诉它使用桌子保留的所有可用宽度?

我希望我正确理解了你的问题。试着设置

android:layout_weight="1"

对于TableRow中的LinearLayout,这无疑是一个更为复杂的问题,因为我不认为您可以使用TableLayout自然地实现这一点,但是您可以在父级和子级上设置ClipChildren=false和SetClipPadding=false,然后动态强制ProgressBar的宽度等于列宽+列宽*百分比,并使用左对齐重力和设置为在其父级上包裹内容的宽度,它可能能够延伸到屏幕边界之外。但是,这仅适用于父表也扩展到该范围的情况
______________________________
|Text1-1|Value1-2|           |
|Text2-1|Value2-2|           |
|Text3-1|Value3-2|===        |
android:layout_weight="1"