2012-12-01 36 views
0

我用下面的布局(缩短):为什么textviews不可见?

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android" ...> 
    <TableRow ...> 
    <TextView 
     android:id="@+id/sell_text" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:text="@string/sell" /> 
    <SeekBar 
     android:id="@+id/sell" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" /> 
    </TableRow> 
</TableLayout> 

这样的(也缩短):

LayoutInflater inflater = parent.getLayoutInflater(); 
View layout = inflater.inflate(R.layout.merger_sale, null); 
AlertDialog.Builder builder = new AlertDialog.Builder(parent); 
builder.setTitle(R.string.sell_stock_after_merger) 
.setView(layout) 
.setPositiveButton(R.string.sell_all, new OnClickListener() {... 
.setNeutralButton(R.string.trade_sell, new OnClickListener() {... 
.setNegativeButton(R.string.trade_all, new OnClickListener() {... 
AlertDialog dialog = builder.create(); 
dialog.show(); 

布局没有错误,也没有代码。布局显示与Eclipse的布局编辑器完全相同。 对话框出现时应该出现,除了texview(@ + id/sell_text)[和缩短的< TableRow> s]中没有出现的按钮行为应该如何应用。

我在忽略什么?谢谢!

回答

0

我认为这将工作,如果你改变宽度和高度来包装内容而不是match_parent。

match_parent表示它可以填充整个布局。

或者尝试给权重,每个项目就像值layout_weight为0。这可以工作,要么

0

尝试:

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" > 

    <TableRow ...> 
    <TextView 
     android:id="@+id/sell_text" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:text="@string/sell" /> 
    <SeekBar 
     android:id="@+id/sell" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" /> 
    </TableRow> 
</TableLayout> 
+0

tablerow的覆盖其子女layout_width和layout_height属性。 – pouzzler