当前位置: 首页>>代码示例>>Java>>正文


Java TableLayout.setLayoutParams方法代码示例

本文整理汇总了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;
}
 
开发者ID:AlexeyZatsepin,项目名称:CP-Tester,代码行数:8,代码来源:ViewHelper.java

示例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;
}
 
开发者ID:Nulltilus,项目名称:Appmatic-Android,代码行数:51,代码来源:ViewParsingUtils.java

示例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;
}
 
开发者ID:irshuLx,项目名称:Android-WYSIWYG-Editor,代码行数:7,代码来源:ListItemExtensions.java

示例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();
}
 
开发者ID:denghuichao,项目名称:flashing_math,代码行数:58,代码来源:MainActivity.java


注:本文中的android.widget.TableLayout.setLayoutParams方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。