本文整理汇总了Java中android.widget.TableLayout.setLayoutParams方法的典型用法代码示例。如果您正苦于以下问题:Java TableLayout.setLayoutParams方法的具体用法?Java TableLayout.setLayoutParams怎么用?Java TableLayout.setLayoutParams使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.TableLayout
的用法示例。
在下文中一共展示了TableLayout.setLayoutParams方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTableView
import android.widget.TableLayout; //导入方法依赖的package包/类
public static TableLayout getTableView(Context context){
TableLayout table = new TableLayout(context);
table.setLayoutParams(new TableLayout.LayoutParams(
TableLayout.LayoutParams.MATCH_PARENT,
TableLayout.LayoutParams.MATCH_PARENT));
return table;
}
示例2: inflateTable
import android.widget.TableLayout; //导入方法依赖的package包/类
private static TableLayout inflateTable(Context context, String tableContent, String[] extras,
boolean isFirstView, boolean isLastView) {
TableLayout tableLayout = new TableLayout(context);
String[] rows = tableContent.split(Content.TABLE_ROW_DIVIDER);
int primaryColor = ContextCompat.getColor(context, R.color.colorPrimary);
int stripColor = Color.argb(35, Color.red(primaryColor), Color.green(primaryColor), Color.blue(primaryColor));
TableLayout.LayoutParams tableParams = new TableLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT);
TableRow.LayoutParams rowParams = new TableRow.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT);
tableLayout.setLayoutParams(tableParams);
tableLayout.setStretchAllColumns(true);
for (int i = 0; i < rows.length; i++) {
TableRow tableRow = new TableRow(context);
tableRow.setLayoutParams(rowParams);
if (Arrays.asList(extras).contains(Content.EXTRA_HAS_STRIPES) && i % 2 != 0)
tableRow.setBackgroundColor(stripColor);
if (Arrays.asList(extras).contains(Content.EXTRA_HAS_HEADER) && i == 0)
tableRow.setBackgroundResource(R.drawable.bottom_tablerow_border);
String[] rowCells = rows[i].split(Content.TABLE_COLUMN_DIVIDER);
for (int j = 0; j < rowCells.length; j++) {
TextView tvCell = new TextView(context);
tvCell.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16.0f);
tvCell.setText(rowCells[j]);
tvCell.setTextColor(ContextCompat.getColor(context, R.color.mainTextColor));
int padding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8,
context.getResources().getDisplayMetrics());
tvCell.setPadding(padding, i == 0 ? 0 : padding, padding, padding);
if (Arrays.asList(extras).contains(Content.EXTRA_HAS_HEADER) && i == 0) {
tableRow.setBackgroundResource(R.drawable.bottom_tablerow_border);
tvCell.setTypeface(null, Typeface.BOLD);
}
if (j == rowCells.length - 1)
tvCell.setGravity(GravityCompat.END);
tableRow.addView(tvCell);
}
tableLayout.addView(tableRow);
}
if (isFirstView && isLastView)
setViewMargins(tableLayout, 0, defaultMargin, 0, 0);
else if (isFirstView)
setViewMargins(tableLayout, 0, defaultMargin, 0, halfMargin);
else if (isLastView)
setViewMargins(tableLayout, 0, halfMargin, 0, 0);
else
setViewMargins(tableLayout, 0, halfMargin, 0, halfMargin);
return tableLayout;
}
示例3: CreateTable
import android.widget.TableLayout; //导入方法依赖的package包/类
public TableLayout CreateTable() {
TableLayout table = new TableLayout(editorCore.getContext());
table.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
table.setPadding(30, 10, 10, 10);
return table;
}
示例4: initUi
import android.widget.TableLayout; //导入方法依赖的package包/类
private void initUi() {
container = (RelativeLayout) findViewById(R.id.container);
num1Tv = (TextView) findViewById(R.id.num1);
num2Tv = (TextView) findViewById(R.id.num2);
opTv = (TextView) findViewById(R.id.fuhao);
resultTv = (TextView) findViewById(R.id.result);// TODO Auto-generated method stub
equalsOp = (TextView) findViewById(R.id.equalsOp);// TODO Auto-generated method stub
bestScoreTv = (TextView) findViewById(R.id.bestscore);
currentScoreTv = (TextView) findViewById(R.id.currentscore);
numOfRightTv = (TextView) findViewById(R.id.numOfRight);
title = (TextView) findViewById(R.id.title);
bestTitle = (TextView) findViewById(R.id.bestText);
scoreTitle = (TextView) findViewById(R.id.scoreText);
bestScoreTv.setText(highestSore + "");
currentScoreTv.setText(currentScore + "");
bestScoreTv.setAnimation(AnimationUtils.loadAnimation(this, R.anim.zoomin));
currentScoreTv.setAnimation(AnimationUtils.loadAnimation(this, R.anim.zoomin));
table = (TableLayout) findViewById(R.id.table);
LayoutParams params = (LayoutParams) table.getLayoutParams();
params.width = this.getResources().getDisplayMetrics().widthPixels;
params.height = params.width;
table.setLayoutParams(params);
progress = (ProgressBar) findViewById(R.id.progress);
progress.setMax(100);
btns[0] = (Button) findViewById(R.id.id1);
btns[1] = (Button) findViewById(R.id.id2);
btns[2] = (Button) findViewById(R.id.id3);
btns[3] = (Button) findViewById(R.id.id4);
btns[4] = (Button) findViewById(R.id.id5);
btns[5] = (Button) findViewById(R.id.id6);
btns[6] = (Button) findViewById(R.id.id7);
btns[7] = (Button) findViewById(R.id.id8);
btns[8] = (Button) findViewById(R.id.id9);
num1Tv.setTypeface(tf);//
num2Tv.setTypeface(tf);//
opTv.setTypeface(tf);//
resultTv.setTypeface(tf);//
equalsOp.setTypeface(tf);//
currentScoreTv.setTypeface(tf);//
bestScoreTv.setTypeface(tf);//
title.setTypeface(tf);//=(TextView) findViewById(R.id.title);
bestTitle.setTypeface(tf);//=(TextView) findViewById(R.id.besttext);
scoreTitle.setTypeface(tf);//=(TextView) findViewById(R.id.scoreText);
numOfRightTv.setTypeface(tf);//=(TextView) findViewById(R.id.scoreText);
for (int i = 0; i < btns.length; i++) {
btns[i].setTypeface(tf);//
}
showUI();
}