Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/oop/2.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 TableLayout中的右对齐列_Android_Tablelayout - Fatal编程技术网

Android TableLayout中的右对齐列

Android TableLayout中的右对齐列,android,tablelayout,Android,Tablelayout,我想发布一张图片来描述这个问题,但显然我在stackoverflow方面还没有足够的声誉,所以我将尝试描述我正在努力实现的目标 我有一个5列的表格布局。它们由公司名称、职务编号、姓氏、图形垂直分隔符和右箭头按钮组成。我希望分隔符和右箭头按钮在屏幕右侧右对齐。我希望第2列(作业编号)扩展得足够大,以便在不包装的情况下保存整个编号。我希望第1列(公司名称)和第3列(姓氏)填充表的其余部分,如果它们太大,则使用省略号(无文字环绕)。我的表是以编程方式构建的 目前,每当公司名称过长时,分隔符和右箭头就会

我想发布一张图片来描述这个问题,但显然我在stackoverflow方面还没有足够的声誉,所以我将尝试描述我正在努力实现的目标

我有一个5列的表格布局。它们由公司名称、职务编号、姓氏、图形垂直分隔符和右箭头按钮组成。我希望分隔符和右箭头按钮在屏幕右侧右对齐。我希望第2列(作业编号)扩展得足够大,以便在不包装的情况下保存整个编号。我希望第1列(公司名称)和第3列(姓氏)填充表的其余部分,如果它们太大,则使用省略号(无文字环绕)。我的表是以编程方式构建的

目前,每当公司名称过长时,分隔符和右箭头就会被从屏幕右侧推出

以下是my layout.xml:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"
          android:orientation="vertical">
<TextView android:id="@+id/searchResultsFoundTextView"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:textSize="16dp"
          android:text="@string/searchResultsLabel"/>
<ScrollView android:layout_width="fill_parent"
            android:layout_height="fill_parent">
    <TableLayout android:id="@+id/searchResultsTableLayout"
                 android:layout_width="fill_parent"
                 android:layout_height="fill_parent"
                 android:layout_marginTop="10dp"
                 android:stretchColumns="1"
                 android:shrinkColumns="0,2" />
</ScrollView>
</LinearLayout>

任何帮助都将不胜感激。

我通过在第一列中添加LayoutParams权重来解决此问题:

TextView customerNameTextView = new TextView(this);
customerNameTextView.setText(job.getCustomerName());
// --- Added this statement
customerNameTextView.setLayoutParams(new TableRow.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, 1f));
// --- 
customerNameTextView.setEllipsize(TextUtils.TruncateAt.END);
customerNameTextView.setTextSize(FONT_SIZE);
customerNameTextView.setPadding(10, 5, 10, 0);
row.addView(customerNameTextView);

第一列现在展开和收缩,分隔符和按钮始终右对齐。有时客户名称被省略,有时名称被包装,但只要列大小正确,这对我来说并不重要。

我可以通过向第一列添加LayoutParams权重来解决这一问题:

TextView customerNameTextView = new TextView(this);
customerNameTextView.setText(job.getCustomerName());
// --- Added this statement
customerNameTextView.setLayoutParams(new TableRow.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, 1f));
// --- 
customerNameTextView.setEllipsize(TextUtils.TruncateAt.END);
customerNameTextView.setTextSize(FONT_SIZE);
customerNameTextView.setPadding(10, 5, 10, 0);
row.addView(customerNameTextView);
第一列现在展开和收缩,分隔符和按钮始终右对齐。有时客户名称被省略,有时名称被包装,但这对我来说并不重要,只要列大小正确