我有一个小剪辑的问题,我一直无法使用通过tablerow一个EditText视图来解决.无论我尝试,所述的EditText视图要么剪切(附截图),或者,如果设置了shrinkColumns为0或1,标签文本消失(和的EditText视图占据整个宽度).布局如下:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:orientation="vertical" android:padding="10dip">
<TableLayout android:orientation="vertical"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<TableRow android:orientation="horizontal"
android:layout_width="fill_parent" android:layout_height="wrap_content">
<TextView android:paddingRight="10dip" android:layout_column="1"
android:text="Label Text" />
<EditText android:text="Very long text that makes the text view go on clipping frenzy"
android:layout_width="wrap_content" android:layout_height="wrap_content" />
</TableRow>
</TableLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
我试过它在QVGA和HVGA,一个的HTC Hero上2.1和野火2.1上运行,以及一个2.2模拟器.我也玩过clipToPadding属性,这在我的情况下似乎没什么帮助.如果我使用长文本设置提示属性并将文本值保留为空,则会出现相同的问题.
由于我没有做任何特别复杂的事情,我怀疑我身边有一个简单的错误.任何想法,提示或建议都非常感谢.
干杯!

我正在开发一个应用程序,我正在寻找一些一般指导:
该应用程序是一个记忆培训师,将有几种不同的模式:
问题是:我可以使用单个xml布局文件来完成此操作,并且我应该为每个布局文件使用相同的布局类型(如果是,那应该是什么!)?这是一个很大的应用程序,所以一致性将是天堂般的.
我更喜欢灵活的布局,现在我倾向于GridView.
有什么想法吗?
我试图填充一个tablelayout与单元格和行拉伸填充整个屏幕.像这样:
http://imageshack.us/photo/my-images/69/device20120201005942.png/
在Eclipse的Graphical Layout窗口中设计的这个布局给出了我想要的东西(android:layout_weight解决了垂直拉伸):
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:stretchColumns="*" >
<TableRow
android:id="@+id/tableRow1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center" android:layout_weight="1">
<ImageView
android:id="@+id/imageView1"
android:layout_gravity="center"
android:src="@drawable/add" />
<ImageView
android:id="@+id/imageView2"
android:layout_gravity="center"
android:src="@drawable/bound" />
<ImageView
android:id="@+id/imageView3"
android:layout_gravity="center"
android:src="@drawable/cod" />
</TableRow>
<TableRow
android:id="@+id/tableRow2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1" >
<ImageView
android:id="@+id/imageView4"
android:layout_gravity="center"
android:src="@drawable/delete" />
<ImageView
android:id="@+id/imageView5"
android:layout_gravity="center"
android:src="@drawable/delete2" />
<ImageView
android:id="@+id/imageView6"
android:layout_gravity="center"
android:src="@drawable/floppy" />
</TableRow>
</TableLayout>
Run Code Online (Sandbox Code Playgroud)
我试图在代码中创建相同的外观但到目前为止失败.这是我的活动的创建:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.tablelo);
TableLayout tl = (TableLayout) findViewById(R.id.table);
Log.d(TAG, "Width :" + tl.getWidth());
for (int …Run Code Online (Sandbox Code Playgroud) 我想在CSS中布局一个表.要求如下:第一列扩展为多,因为它可以和第一列文本被限制为一行文本,如果有更多的,应该有一个省略号.其他列只需要他们需要包含他们的文本不换行(文本换行:NOWRAP)的空间.
桌子本身宽度为100%.
我设法有省略号无论是固定大小的第一列,没有省略号可变大小的第一列,我不能找到一种方法,具有可变大小的列用省略号.用CSS可以实现吗?如果需要,我可以使用CSS 3属性,但我想避免使用JS.
标记:
<table class="table">
<tr>
<th>First</th>
<th class="no-wrap">Second</th>
</tr>
<tr>
<td class="expand-column">
Some long long text here
</td>
<td class="no-wrap">
Other text
</td>
</tr>
</table>
Run Code Online (Sandbox Code Playgroud)
CSS:
.table, .expand-column {
width: 100%;
}
.no-wrap {
white-space: nowrap;
}
Run Code Online (Sandbox Code Playgroud) 祝大家有个美好的一天。
我的每一行都有TableLayout三个TextViews。是否仍然可以添加OnClickListener到整行?我想更改所选行的背景颜色。我已经设定OnClickListener为TableRow通过执行以下,但背景颜色不会改变:
for(int i =0; i < rowAmount; i++)
{
TableRow tr= new TableRow(this);
TextView rmNo;
TextView s;
TextView p;
rmNo = new TextView(this);
s = new TextView(this);
p = new TextView(this);
rmNo.setText("" + roomNumbers.get(i).toString());
s.setText("" + statuses.get(i).toString());
p.setText("" + priorities.get(i).toString());
tr.addView(rmNo);
tr.addView(s);
tr.addView(p);
tr.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
tr.setBackgroundColor(color.holo_blue_light);
}
});
tblContent.addView(tr);
}
}
Run Code Online (Sandbox Code Playgroud)
我正在以编程方式创建 TableRows 和 TextViews,因为它们的数据是从数据库中检索的。
这是 XML:
<ScrollView
android:id="@+id/scroll"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/tblTitles"> …Run Code Online (Sandbox Code Playgroud) 我有一个表格布局(带有房地产过滤参数的表格)。当用户从Spinner列表(公寓、房屋、土地等)中选择不动产类型时,我需要隐藏/显示带有过滤参数的行。是否可以?TableLayout 对此有好处还是使用 LinearLayout 会更好?什么时候使用 TableLayout 优于 LinearLayout?我有一个简单的水平表格,看起来像这样:
-------------------------
field name: [input field]
-------------------------
field name: [input field]
-------------------------
Run Code Online (Sandbox Code Playgroud)
我已经发现我可以删除/添加行:
tableLayout.addView(row);
tableLayout.removeView(row);
Run Code Online (Sandbox Code Playgroud)
这是唯一的方法吗?我可以只隐藏/显示行而不删除它们吗?
我有一个<table>包含多个cols 的HTML .在任何情况下,如何确保给定的单元格/ col宽度?也就是说,如果我给单元格宽度为100px并且文本内容很长(超过100个字符而没有任何空格),则文本内容应该遵循100px宽度并换行到下一行.
我已经尝试过使用word-wrap:break-word,但这不起作用.
请帮我.
我希望你能帮助我.我想创建动态表(截图).我是通过以下代码创建的:
TableLayout tl = (TableLayout) findViewById(R.id.main_table);
FOR. 1-300.........
TableRow tr_head = new TableRow(this);
tr_head.setId(10);
tr_head.setBackgroundColor(Color.CYAN);
tr_head.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT));
RelativeLayout rl = new RelativeLayout(this);
rl.setId(20);
ImageButton xyz = new ImageButton(this);
xyz.setId(21);
xyz.setPadding(5, 5, 5, 5);
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT );
params.addRule(RelativeLayout.ALIGN_PARENT_LEFT, 20 );
rl.addView(xyz,params);
tr_head.addView(rl);
tl.addView(tr_head, new TableLayout.LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT));
END OF FOR.......
Run Code Online (Sandbox Code Playgroud)
通过类似的代码,我很好地创建了两种类型的项目,一种用于类别(3个子视图),一种用于类别项目(10个子视图).然后我使用代码bellow为按钮和整个项目分配onclick监听器:
int count = tl.getChildCount();
for(int i = 0; i < count; i++){
TableRow v = (TableRow)tl.getChildAt(i);
if(v.getChildAt(0) instanceof RelativeLayout){
RelativeLayout relativ = (RelativeLayout)v.getChildAt(0);
if(relativ.getChildCount()>5)
relativ.setOnClickListener(new MyClickListener());
........... …Run Code Online (Sandbox Code Playgroud) java"Clearthought"TableLayout项目的状态是什么?
它还在维护吗?
什么是最新的网站?
旧页:http: //www.clearthought.info/sun/products/jfc/tsc/articles/tablelayout/
不工作:https: //tablelayout.dev.java.net/
2005版的maven存储库:http: //mvnrepository.com/artifact/tablelayout/TableLayout/20050920
还有其他更新的页面吗?
我希望ScrollView TableLayout与屏幕具有相同的高度,但是为什么表只占用屏幕的一半,而ScrollView正按照预期全屏显示.
我尝试将table和rows的高度更改为wrap_content,但显示相同的结果.同样将桌子的高度改变为固定高度(例如900dp)也不起作用.即使最后一行高度也没有显示完整的评级栏.似乎表格被迫具有特定的宽度.
如果我删除ScrollView,它的工作正常.
谁能请帮忙.
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:background="@drawable/border"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".EditEntry" >
<TableLayout
android:id="@+id/tableLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TableRow
android:id="@+id/tr3a"
android:padding="2.5dp"
android:background="@color/col1"
android:gravity="center_vertical"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1" >
<TextView
android:id="@+id/lab_bookname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/bookname" />
<EditText
android:id="@+id/bookname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="@string/definputtext2" />
</TableRow>
<TableRow
android:id="@+id/tr3"
android:padding="2.5dp"
android:background="@color/col2"
android:gravity="center_vertical"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1" >
<TextView
android:id="@+id/lab_printname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/print_name" />
<EditText
android:id="@+id/printname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="@string/definputtext2" />
</TableRow>
......................
......................
......................
</TableLayout>
</ScrollView>
Run Code Online (Sandbox Code Playgroud)
