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


Java TableLayout.LayoutParams方法代码示例

本文整理汇总了Java中android.widget.TableLayout.LayoutParams方法的典型用法代码示例。如果您正苦于以下问题:Java TableLayout.LayoutParams方法的具体用法?Java TableLayout.LayoutParams怎么用?Java TableLayout.LayoutParams使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.widget.TableLayout的用法示例。


在下文中一共展示了TableLayout.LayoutParams方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setViewMargin

import android.widget.TableLayout; //导入方法依赖的package包/类
/**
 * 设置View的Margin
 *
 * @param view
 * @param left
 * @param top
 * @param right
 * @param bottom
 * @param width
 * @param height
 */
public void setViewMargin(View view, int left, int top, int right, int bottom, int width, int height) {
    if (view == null) {
        return;
    }
    ViewParent parent = view.getParent();
    if (parent == null) {
        return;
    }
    ViewGroup.MarginLayoutParams lp;
    if (parent instanceof LinearLayout) {
        lp = new LinearLayout.LayoutParams(width, height);
    } else if (parent instanceof RelativeLayout) {
        lp = new RelativeLayout.LayoutParams(width, height);
    } else if (parent instanceof FrameLayout) {
        lp = new FrameLayout.LayoutParams(width, height);
    } else {
        lp = new TableLayout.LayoutParams(width, height);
    }
    if (lp != null) {
        lp.setMargins(left, top, right, bottom);
        view.setLayoutParams(lp);
    }
}
 
开发者ID:AriesHoo,项目名称:TitleBarView,代码行数:35,代码来源:ViewUtil.java

示例2: makeRemarkList

import android.widget.TableLayout; //导入方法依赖的package包/类
private void makeRemarkList(){

        if(remarks.size() > 0){
            tv_msg_remark.setVisibility(View.GONE);
        }else{
            tv_msg_remark.setVisibility(View.VISIBLE);
        }

        for(PatientRemark pr : remarks){

            TableLayout.LayoutParams tlps=new TableLayout.LayoutParams(TableLayout.LayoutParams.WRAP_CONTENT,TableLayout.LayoutParams.WRAP_CONTENT);
            TableRow.LayoutParams trps=new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT,TableRow.LayoutParams.WRAP_CONTENT);

            TableRow tr = new TableRow(this);
            tr.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.WRAP_CONTENT));

            TextView tv_title = new TextView(this);
            tv_title.setText(pr.getDescription());
            tv_title.setLayoutParams(trps);
            tv_title.setTextColor(getColorId(R.color.dark_gray));
            tv_title.setGravity(Gravity.CENTER);
            tv_title.setTextSize(TypedValue.COMPLEX_UNIT_PX,
                    getResources().getDimension(R.dimen.default_font_small_size));

            TextView tv_time = new TextView(this);
            tv_time.setText(AdditionalFunc.getTimeString(pr.getRegisteredDate()));
            tv_time.setLayoutParams(trps);
            tv_time.setTextColor(getColorId(R.color.dark_gray));
            tv_time.setGravity(Gravity.CENTER);
            tv_time.setTextSize(TypedValue.COMPLEX_UNIT_PX,
                    getResources().getDimension(R.dimen.default_font_small_size));

            tr.addView(tv_title);
            tr.addView(tv_time);

            tl_remark.addView(tr, tlps);
        }

    }
 
开发者ID:pooi,项目名称:Nearby,代码行数:40,代码来源:InquiryDateDetailActivity.java

示例3: addButtonForNetwork

import android.widget.TableLayout; //导入方法依赖的package包/类
private void addButtonForNetwork(AccessPointInfo info) {

        TableLayout s = (TableLayout) findViewById(R.id.table_networks);
        TableLayout.LayoutParams tableParams = new TableLayout.LayoutParams(
                        LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
        TableRow row = new TableRow(this);
        TableRow.LayoutParams rowParams = new TableRow.LayoutParams(LayoutParams.MATCH_PARENT,
                        LayoutParams.WRAP_CONTENT);
        rowParams.gravity = Gravity.FILL_HORIZONTAL;
        row.setPadding(10, 10, 10, 10);
        row.setLayoutParams(rowParams);
        row.setGravity(Gravity.FILL_HORIZONTAL);
        row.setLayoutParams(rowParams);

        NetworkButton button = new NetworkButton(this, info.getBssid());

        TableRow.LayoutParams params = new TableRow.LayoutParams(LayoutParams.MATCH_PARENT,
                        LayoutParams.WRAP_CONTENT);
        button.setLayoutParams(params);
        button.setBackground(getResources().getDrawable(R.drawable.repwifi_button));
        button.setTextColor(Commons.colorThemeLight);
        button.setTextSize(20);
        button.setPadding(25, 10, 25, 10);
        button.setGravity(Gravity.CENTER_HORIZONTAL);
        button.setText(info.getSsid(20));
        button.setOnClickListener(this);

        row.addView(button, params);
        row.setGravity(Gravity.CENTER_HORIZONTAL);
        s.addView(row, tableParams);
        s.setGravity(Gravity.FILL_HORIZONTAL);

    }
 
开发者ID:vaginessa,项目名称:RepWifiApp,代码行数:34,代码来源:SelectNetworkActivity.java

示例4: onBindViewHolder

import android.widget.TableLayout; //导入方法依赖的package包/类
@Override
public void onBindViewHolder(final ViewHolder holder, int position) {
    final MainRecord mr = list.get(position);
    final int pos = position;

    holder.tv_dateTitle.setText(mr.getDate());

    ArrayList<MainRecord> groupList = mr.getGroupList();
    for(int i=0; i<groupList.size(); i++){
        MainRecord mr2 = groupList.get(i);

        VitalSign vs = (VitalSign)mr2;

        TableLayout.LayoutParams tlps=new TableLayout.LayoutParams(TableLayout.LayoutParams.WRAP_CONTENT,TableLayout.LayoutParams.WRAP_CONTENT);
        TableRow.LayoutParams trps=new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT,TableRow.LayoutParams.WRAP_CONTENT);

        TableRow tr = new TableRow(context);
        tr.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.WRAP_CONTENT));


        TextView tv_title = new TextView(context);
        switch (type){
            case InquiryVitalSignFragment.TYPE_PULSE: {
                tv_title.setText(vs.getPulse() + "");
                break;
            }
            case InquiryVitalSignFragment.TYPE_TEMPERATURE:{
                tv_title.setText(vs.getTemperature() + "");
                break;
            }
            case InquiryVitalSignFragment.TYPE_BP:{
                tv_title.setText(vs.getBpMin() + " / " + vs.getBpMax());
                break;
            }
        }
        tv_title.setLayoutParams(trps);
        tv_title.setTextColor(recordSupporter.getColorId(R.color.dark_gray));
        tv_title.setGravity(Gravity.CENTER);
        tv_title.setTextSize(TypedValue.COMPLEX_UNIT_PX,
                context.getResources().getDimension(R.dimen.default_font_small_size));

        tr.addView(tv_title);


        TextView tv_time = new TextView(context);
        tv_time.setText(AdditionalFunc.getTimeString(vs.getRegisteredDate()));
        tv_time.setLayoutParams(trps);
        tv_time.setTextColor(recordSupporter.getColorId(R.color.dark_gray));
        tv_time.setGravity(Gravity.CENTER);
        tv_time.setTextSize(TypedValue.COMPLEX_UNIT_PX,
                context.getResources().getDimension(R.dimen.default_font_small_size));

        tr.addView(tv_time);

        holder.tl.addView(tr, tlps);


    }

}
 
开发者ID:pooi,项目名称:Nearby,代码行数:61,代码来源:AllInOneInquiryVitalListCustomAdapter.java

示例5: makeMealList

import android.widget.TableLayout; //导入方法依赖的package包/类
private void makeMealList(){

        if(haveMeals.size() > 0){
            tv_msg_meal.setVisibility(View.GONE);
        }else{
            tv_msg_meal.setVisibility(View.VISIBLE);
        }

        for(HaveMeal hm : haveMeals){

            TableLayout.LayoutParams tlps=new TableLayout.LayoutParams(TableLayout.LayoutParams.WRAP_CONTENT,TableLayout.LayoutParams.WRAP_CONTENT);
            TableRow.LayoutParams trps=new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT,TableRow.LayoutParams.WRAP_CONTENT);

            TableRow tr = new TableRow(this);
            tr.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.WRAP_CONTENT));

            TextView tv_title = new TextView(this);
            if("nursing_home".equals(hm.getType())){
                tv_title.setText(getString(R.string.nursing_home_meal_srt));
            }else if("water_gruel".equals(hm.getType())){
                tv_title.setText(getString(R.string.water_gruel));
            }else{
                tv_title.setText(hm.getType());
            }
            tv_title.setLayoutParams(trps);
            tv_title.setTextColor(getColorId(R.color.dark_gray));
            tv_title.setGravity(Gravity.CENTER);
            tv_title.setTextSize(TypedValue.COMPLEX_UNIT_PX,
                    getResources().getDimension(R.dimen.default_font_small_size));

            TextView tv_time = new TextView(this);
            tv_time.setText(AdditionalFunc.getTimeString(hm.getRegisteredDate()));
            tv_time.setLayoutParams(trps);
            tv_time.setTextColor(getColorId(R.color.dark_gray));
            tv_time.setGravity(Gravity.CENTER);
            tv_time.setTextSize(TypedValue.COMPLEX_UNIT_PX,
                    getResources().getDimension(R.dimen.default_font_small_size));

            tr.addView(tv_title);
            tr.addView(tv_time);

            tl_meal.addView(tr, tlps);
        }

    }
 
开发者ID:pooi,项目名称:Nearby,代码行数:46,代码来源:InquiryDateDetailActivity.java

示例6: makeList

import android.widget.TableLayout; //导入方法依赖的package包/类
private void makeList(String type){

        ArrayList<NearbyLog> list = new ArrayList<>();
        TableLayout tl = null;

        switch (type){
            case "symptom": {
                list = symptomList;
                tl = tl_symptom;
                break;
            }
            case "medicine": {
                list = medicineList;
                tl = tl_medicine;
                break;
            }
            case "record": {
                list = recordList;
                tl = tl_record;
                break;
            }
            case "weight": {
                list = weightList;
                tl = tl_weight;
                break;
            }
            case "edit_patient": {
                list = editPatientList;
                tl = tl_edit_patient;
                break;
            }
            case "supporter": {
                list = supporterList;
                tl = tl_supporter;
                break;
            }
        }

        if(tl != null){


            for(int i= Math.max(0, list.size()-5); i<list.size(); i++){
                NearbyLog log = list.get(i);

                TableLayout.LayoutParams tlps=new TableLayout.LayoutParams(TableLayout.LayoutParams.WRAP_CONTENT,TableLayout.LayoutParams.WRAP_CONTENT);
                TableRow.LayoutParams trps=new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT,TableRow.LayoutParams.WRAP_CONTENT);

                TableRow tr = new TableRow(this);
                tr.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.WRAP_CONTENT));

                TextView tv_log_msg = new TextView(this);
                tv_log_msg.setText(log.getMsg());
                tv_log_msg.setLayoutParams(trps);
                tv_log_msg.setTextColor(getColorId(R.color.dark_gray));
                tv_log_msg.setGravity(Gravity.CENTER);
                tv_log_msg.setTextSize(TypedValue.COMPLEX_UNIT_PX,
                        getResources().getDimension(R.dimen.default_font_small_size));

                TextView tv_time = new TextView(this);
                tv_time.setText(AdditionalFunc.getDateTimeSrtString(log.getRegisteredDate()));
                tv_time.setLayoutParams(trps);
                tv_time.setTextColor(getColorId(R.color.dark_gray));
                tv_time.setGravity(Gravity.CENTER);
                tv_time.setTextSize(TypedValue.COMPLEX_UNIT_PX,
                        getResources().getDimension(R.dimen.default_font_small_size));

                tr.addView(tv_log_msg);
                tr.addView(tv_time);

                tl.addView(tr, tlps);

            }

        }

    }
 
开发者ID:pooi,项目名称:Nearby,代码行数:77,代码来源:InquiryLogActivity.java

示例7: resize

import android.widget.TableLayout; //导入方法依赖的package包/类
public void resize(int rows, int cols, int cellLayoutId)
{
    if (rowsNumber == rows && colsNumber == cols)
    {
        return;
    }
    rowsNumber = rows;
    colsNumber = cols;

    removeAllViews();
    fields.clear();

    final TableLayout.LayoutParams tableParams = new TableLayout.LayoutParams(
            TableLayout.LayoutParams.WRAP_CONTENT, TableLayout.LayoutParams.WRAP_CONTENT);

    final LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(
            Context.LAYOUT_INFLATER_SERVICE);

    for (int row = 0; row < rowsNumber; row++)
    {
        final TableRow tableRow = new TableRow(getContext());
        tableRow.setLayoutParams(tableParams); // TableLayout is the parent view
        addView(tableRow);

        for (int col = 0; col < colsNumber; col++)
        {
            inflater.inflate(cellLayoutId, tableRow);
        }

        if (tableRow.getChildCount() > 0)
        {
            tableRow.setBaselineAligned(true);
            tableRow.setBaselineAlignedChildIndex(0);
        }

        for (int col = 0; col < tableRow.getChildCount(); col++)
        {
            final CustomEditText c = (CustomEditText) tableRow.getChildAt(col);
            if (c != null)
            {
                c.setId(IdGenerator.generateId());
                c.setTag(new ElementTag(row, col, fields.size()));
                fields.add(c);
            }
        }
    }

    setPadding(0, 0, 0, 0);
    setBaselineAligned(true);
    setBaselineAlignedChildIndex(rowsNumber > 1 ? rowsNumber / 2 : 0);
}
 
开发者ID:mkulesh,项目名称:microMathematics,代码行数:52,代码来源:ResultMatrixLayout.java

示例8: 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

示例9: updateHorizontalSeparator

import android.widget.TableLayout; //导入方法依赖的package包/类
private void updateHorizontalSeparator(TableRow tableRow) {
    TableLayout.LayoutParams tableRowParams = (TableLayout.LayoutParams) tableRow.getLayoutParams();
    tableRowParams.setMargins(0, 0, 0, mHorizontalSeparatorMargin);
    tableRow.setLayoutParams(tableRowParams);
}
 
开发者ID:joan-domingo,项目名称:CustomNumberPad,代码行数:6,代码来源:NumPadView.java


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