當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。