Android 如何以编程方式在tablerow中添加seekbar?
我有一个表布局,我想通过编程在每一行中添加seekbar。我该怎么做。。。?我已经有了seekbar的xml布局,但是如何以编程方式将其添加到tablerow 编辑:我还想显示除法器值,比如如果分配给seekbar的最大值是5,那么我想在seekbar下面显示0、1、2、3、4和5 试试这个Android 如何以编程方式在tablerow中添加seekbar?,android,tablerow,android-seekbar,Android,Tablerow,Android Seekbar,我有一个表布局,我想通过编程在每一行中添加seekbar。我该怎么做。。。?我已经有了seekbar的xml布局,但是如何以编程方式将其添加到tablerow 编辑:我还想显示除法器值,比如如果分配给seekbar的最大值是5,那么我想在seekbar下面显示0、1、2、3、4和5 试试这个 TableRow tr = new TableRow(this); tr.setLayoutParams(new TableRow.LayoutParams(TableRow.La
TableRow tr = new TableRow(this);
tr.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.FILL_PARENT, TableRow.LayoutParams.WRAP_CONTENT));
/* Create a SeekBar to be the row-content. */
SeekBar seekBar = new SeekBar(this);
seekBar.setMax(15);
// seekBar.setIndeterminate(true);
ShapeDrawable thumb = new ShapeDrawable(new OvalShape());
thumb.setIntrinsicHeight(80);
thumb.setIntrinsicWidth(30);
seekBar.setThumb(thumb);
seekBar.setProgress(1);
seekBar.setVisibility(View.VISIBLE);
seekBar.setBackgroundColor(Color.BLUE);
LayoutParams lp = new LayoutParams(200, 50);
seekBar.setLayoutParams(lp);
seekBar.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.FILL_PARENT, TableRow.LayoutParams.WRAP_CONTENT));
我添加了seekbar,但它的大小很小。如何增加它的尺寸?我已经读到布局和重量是用来使seekbar正确可见的。在这种情况下它有用吗??