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


Java TextView.setHeight方法代码示例

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


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

示例1: inflateTextView

import android.widget.TextView; //导入方法依赖的package包/类
private TextView inflateTextView() {
    GradientDrawable shape = new GradientDrawable();
    shape.setCornerRadius(8);
    shape.setColor(0xff000000 | mRandom.nextInt(0x00ffffff));
    TextView textView = new TextView(this);
    textView.setGravity(Gravity.CENTER);
    textView.setTextColor(Color.WHITE);
    textView.setWidth(150 + mRandom.nextInt(3) * 50);
    textView.setHeight(150 + mRandom.nextInt(3) * 50);
    textView.setTextSize(32);
    if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN) {
        textView.setBackgroundDrawable(shape);
    } else {
        textView.setBackground(shape);
    }
    textView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(final View view) {
            mList.removeViewWithAnimation(view);
        }
    });
    textView.setText(String.format(Locale.JAPAN, "%1$02d", mCounter++));
    return textView;
}
 
开发者ID:sjnyag,项目名称:AnimationWrapLayout,代码行数:25,代码来源:MainActivity.java

示例2: makeCenterView

import android.widget.TextView; //导入方法依赖的package包/类
@Override
@NonNull
protected LinearLayout makeCenterView() {
    LinearLayout rootLayout = new LinearLayout(activity);
    rootLayout.setLayoutParams(new LinearLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT));
    rootLayout.setOrientation(LinearLayout.VERTICAL);

    mTextView = new TextView(activity);
    mTextView.setHeight(screenHeightPixels/4);
    mTextView.setLayoutParams(new LinearLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT));
    mTextView.setGravity(Gravity.CENTER);
    mTextView.setTextSize(16);
    mTextView.setPadding(10, 10, 10, 10);
    mTextView.setText(mContent);
    rootLayout.addView(mTextView);

    setTitleText(mTitle);
    return rootLayout;
}
 
开发者ID:mainh,项目名称:MainCalendar,代码行数:20,代码来源:DialogPicker.java

示例3: addStartView

import android.widget.TextView; //导入方法依赖的package包/类
private View addStartView(int startnum, final int week, final int start) {
        LinearLayout mStartView = new LinearLayout(getContext());
        mStartView.setOrientation(VERTICAL);
        for (int i = 1; i < startnum; i++) {
            TextView mTime = new TextView(getContext());
            mTime.setGravity(Gravity.CENTER);
            mTime.setHeight(dip2px(TimeTableHeight));
            mTime.setWidth(dip2px(TimeTableHeight));
            mStartView.addView(mTime);
            mStartView.addView(getWeekTransverseLine());

            //这里可以处理空白处点击添加课表
            final int finalI = i;
            mTime.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
//                    Toast.makeText(getContext(), "星期" + week + "第" + (start + num) + "节", Toast.LENGTH_SHORT).show();
                    //TODO 添加课程
                    mClickListener.onClickScheduleAdd(week,start+ finalI);
                }
            });

        }
        return mStartView;
    }
 
开发者ID:WeGdufe,项目名称:MovingGdufe-Android,代码行数:26,代码来源:ScheduleView.java

示例4: addEmoji

import android.widget.TextView; //导入方法依赖的package包/类
public void addEmoji(List<String> emojis, String storyId) {
    String storyIdMessage = storyId + "-message";
    storyId += "-emoji";

    removeStuffWithThisKey(storyIdMessage);
    removeStuffWithThisKey(storyId);

    int gridThingPixels = (int) myContext.getResources().getDimension(R.dimen.grid_thing);

    for (String emoji : emojis) {
        TextView textThing = new TextView(myContext);
        textThing.setText(emoji);
        textThing.setTextSize(60);
        textThing.setHeight(gridThingPixels);

        gridContents.add(new TaggedView(textThing, storyId));
    }

    this.notifyDataSetChanged();
}
 
开发者ID:mimming,项目名称:zero-to-app-emojistories,代码行数:21,代码来源:StoryAdapter.java

示例5: displaySnackbar

import android.widget.TextView; //导入方法依赖的package包/类
private void displaySnackbar(String snackbarText) {
    Snackbar snackbar = Snackbar.make(relativeLayout, snackbarText, Snackbar.LENGTH_LONG);
    View view = snackbar.getView();
    TextView textView = (TextView) view.findViewById(android.support.design.R.id.snackbar_text);
    textView.setHeight(mTabLayout.getHeight());
    textView.setGravity(Gravity.CENTER_VERTICAL);
    snackbar.show();
}
 
开发者ID:chashmeetsingh,项目名称:TrackIt-Android,代码行数:9,代码来源:MainActivity.java

示例6: MeasureString

import android.widget.TextView; //导入方法依赖的package包/类
public static Point MeasureString(Context context, String text, float fontSize, int widthMeasureSpec, int heightMeasureSpec) {
    int width = 0;
    int height = 0;

    if (null == context || null == text || text.isEmpty() || 0 == fontSize) {
        return null;
    }

    TextView tv = new TextView(context);

    tv.setText(text);// 待测文本
    tv.setTextSize(fontSize);// 字体

    if (ViewGroup.LayoutParams.WRAP_CONTENT != widthMeasureSpec && ViewGroup.LayoutParams.MATCH_PARENT != widthMeasureSpec) {
        tv.setWidth(widthMeasureSpec);// 如果设置了宽度,字符串的宽度则为所设置的宽度
    }

    if (ViewGroup.LayoutParams.WRAP_CONTENT != heightMeasureSpec && ViewGroup.LayoutParams.MATCH_PARENT != heightMeasureSpec) {
        tv.setHeight(heightMeasureSpec);
    }

    tv.setSingleLine(false);// 多行

    tv.measure(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT);

    width = tv.getMeasuredWidth();
    height = tv.getMeasuredHeight();

    Point point = new Point();
    point.x = width;
    point.y = height;

    return point;
}
 
开发者ID:WeiMei-Tian,项目名称:editor-sql,代码行数:35,代码来源:Utils.java

示例7: getWeekTransverseLine

import android.widget.TextView; //导入方法依赖的package包/类
/**
 * 横的分界线
 *
 * @return
 */
private View getWeekTransverseLine() {
    TextView mWeekline = new TextView(getContext());
    mWeekline.setBackgroundColor(getResources().getColor(R.color.view_line));
    mWeekline.setHeight(TimeTableLineHeight);
    mWeekline.setWidth(LayoutParams.FILL_PARENT);
    return mWeekline;
}
 
开发者ID:WeGdufe,项目名称:MovingGdufe-Android,代码行数:13,代码来源:ScheduleView.java

示例8: getWeekVerticalLine

import android.widget.TextView; //导入方法依赖的package包/类
/**
 * 竖向分界线
 *
 * @return
 */
private View getWeekVerticalLine() {
    TextView mWeekline = new TextView(getContext());
    mWeekline.setBackgroundColor(getResources().getColor(R.color.view_line));
    mWeekline.setHeight(dip2px(TimeTableWeekNameHeight));
    mWeekline.setWidth((TimeTableLineHeight));
    return mWeekline;
}
 
开发者ID:WeGdufe,项目名称:MovingGdufe-Android,代码行数:13,代码来源:ScheduleView.java

示例9: getMode

import android.widget.TextView; //导入方法依赖的package包/类
/**
     * 获取单个课表View
     *
     * @param model 数据类型
     * @return
     */
    @SuppressWarnings("deprecation")
    private View getMode(final Schedule model) {
        LinearLayout mScheduleView = new LinearLayout(getContext());
        mScheduleView.setOrientation(VERTICAL);
        TextView mTimeTableNameView = new TextView(getContext());
        int num = model.getEndSec() - model.getStartSec();
        mTimeTableNameView.setHeight(dip2px((num + 1) * TimeTableHeight) + num * 2);
        mTimeTableNameView.setTextColor(getContext().getResources().getColor(
                android.R.color.white));
        mTimeTableNameView.setWidth(dip2px(50));
        mTimeTableNameView.setTextSize(CourseTextSize);
        mTimeTableNameView.setGravity(Gravity.CENTER);
        mTimeTableNameView.setText(model.getName() + "\n" + model.getLocation());
        mScheduleView.addView(mTimeTableNameView);
        mScheduleView.addView(getWeekTransverseLine());
        mScheduleView.setBackgroundDrawable(getContext().getResources()
                .getDrawable(colors[getColorNum(model.getName())]));

        if(mCurrentWeek != FileUtils.SP_WEEK_NOT_SET && !CalcUtils.isCurrentWeek(model.getPeriod(), mCurrentWeek)){
            mScheduleView.setBackgroundDrawable(getContext().getResources()
                    .getDrawable(notGocolors));
//            mTimeTableNameView.setTextColor(getContext().getResources().getColor(
//                    android.R.color.darker_gray));
        }

        mScheduleView.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
//                Toast.makeText(getContext(), model.getName() + "\n" + model.getLocation()+"\n" +model.getPeriod()+"\n"+ model.getTeacher(), Toast.LENGTH_SHORT).show();
                //TODO 编辑课程
                mClickListener.onClickScheduleEdit(model);
            }
        });
        return mScheduleView;
    }
 
开发者ID:WeGdufe,项目名称:MovingGdufe-Android,代码行数:42,代码来源:ScheduleView.java

示例10: setClearingLayoutSizes

import android.widget.TextView; //导入方法依赖的package包/类
public void setClearingLayoutSizes(View rootView, Context context) {

        DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();
        float dpHeight = displayMetrics.heightPixels / displayMetrics.density;
        float dpWidth = displayMetrics.widthPixels / displayMetrics.density;

        dpHeight -= addClearingButton.getHeight();

        dpHeight /= 9;
        dpWidth /= 7;


        int finalValue = (int) Math.min(dpHeight, dpWidth);

        TableLayout table = rootView.findViewById(R.id.clearingGrid);
        final int childcount = table.getChildCount();
        for (int i = 0; i < childcount; i++) {
            TableRow row = (TableRow) table.getChildAt(i);

            final int cellCount = row.getChildCount();
            for (int j = 0; j < cellCount; j++) {
                TextView cell = (TextView) row.getChildAt(j);
                cell.setHeight(finalValue);
                cell.setWidth(finalValue);
            }


        }
    }
 
开发者ID:joaomneto,项目名称:TitanCompanion,代码行数:30,代码来源:SSAdventureMapFragment.java

示例11: initView

import android.widget.TextView; //导入方法依赖的package包/类
/**
 * 密码键盘默认样式
 * @param context
 */
private void initView(Context context) {
    mkeyboardLayout = new LinearLayout(context);
    mkeyboardLayout.setOrientation(LinearLayout.VERTICAL);
    if (null != mKeyBoardBgDrawable) {
        mkeyboardLayout.setBackgroundDrawable(mKeyBoardBgDrawable);
    } else {
        mkeyboardLayout.setBackgroundColor(Color.GRAY);
    }
    LinearLayout.LayoutParams titleParams = new LinearLayout.LayoutParams(
            LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    titleParams.setMargins(0, 0, 0, 6);
    mTitleLayout = new LinearLayout(context);
    mTitleLayout.setGravity(Gravity.CENTER);
    mTitleLayout.setOrientation(LinearLayout.HORIZONTAL);

    mTitleLayout.setLayoutParams(titleParams);
    int titleBackgroundColor = mContext.getResources()
            .getColor(R.color.bg_security_keyboard_title);
    mTitleLayout.setBackgroundColor(titleBackgroundColor);
    mTitleView = new TextView(context);
    mTitleView.setText("Secure Mode");
    mTitleView.setTextColor(Color.WHITE);
    mTitleView.setHeight(getSaftyKeyHeight() / 16);
    mTitleView.setGravity(Gravity.CENTER);
    mTitleLayout.addView(mTitleView);

    mKeyBoardControl = new GrapeGridview(context);
    mKeyBoardControl.setHorizontalScrollBarEnabled(false);
    mKeyBoardControl.setVerticalScrollBarEnabled(false);
    mKeyBoardControl.setEnabled(false);
    mKeyBoardControl.setNumColumns(Constant.COLUMN_SOFT_KEYBOARD);
    mKeyBoardControl.setVerticalSpacing(mMarginRow);
    mKeyBoardControl.setHorizontalSpacing(mMarginCol);
    mKeyBoardControl.setAdapter(mAdapter);

    mkeyboardLayout.addView(mTitleLayout);
    mkeyboardLayout.addView(mKeyBoardControl);
    mkeyboardLayout.setPadding(mPaddingLeft, mPaddingTop, mPaddingRight,
            mPaddingBottom);

    mPopup = new PopupWindow(mkeyboardLayout, mWidth, mHeight);
    mPopup.setBackgroundDrawable(new BitmapDrawable());
    mPopup.setSoftInputMode(
            WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
    mPopup.setOutsideTouchable(true);
    mPopup.setFocusable(true);
    mPopup.setOnDismissListener(dismissListener);
}
 
开发者ID:VigorousLiang,项目名称:PWEditText-SafeKeyboard,代码行数:53,代码来源:SafetyKeyboard.java

示例12: initRowLayout

import android.widget.TextView; //导入方法依赖的package包/类
/**
 * 初始化横向表头的布局,必须在所有的布局都载入完之后才能调用
 * <p>
 * must be called in pl_root.post();
 */
private void initRowLayout() {

    if (rowDataList == null) {
        Log.e("PanelList", "custom Row data list is strongly recommended! Call setRowDataList(List<String> rowDataList) in your panel adapter");
    }
    int rowCount = ll_contentItem.getChildCount();

    List<String> rowDataList1 = getRowDataList(rowCount);

    //分隔线的设置,如果content的item设置了分割线,那row使用相同的分割线,除非单独给row设置了分割线
    ll_row.setBackgroundColor(Color.parseColor(rowColor));
    if (rowDivider == null) {
        ll_row.setDividerDrawable(ll_contentItem.getDividerDrawable());
    } else {
        ll_row.setDividerDrawable(rowDivider);
    }

    // 获得row一共有多少个item,然后使用循环往里面添加对应个数个TextView(简单粗暴)
    for (int i = 0; i < rowCount; i++) {
        View contentItem = ll_contentItem.getChildAt(i);// 获得item的item,以便获取宽度
        TextView rowItem = new TextView(context);
        rowItem.setText(rowDataList1.get(i));//设置文字
        Paint rowPaint=rowItem.getPaint();
        rowPaint.setFakeBoldText(false);
        rowPaint.setColor(context.getResources().getColor(R.color.color_646464));
        rowPaint.setTextSize(CommonUtils.dp2px(context,15));
        rowItem.setWidth(contentItem.getWidth()-2);//设置宽度
        rowItem.setHeight(titleHeight);//设置高度
        rowItem.setGravity(Gravity.CENTER);
        TextView line=new TextView(context);
        ll_row.addView(rowItem);
        if (i<rowCount-1){
            line.setBackgroundColor(Color.WHITE);
            line.setWidth(2);
            line.setHeight(titleHeight);
            ll_row.addView(line);
        }


    }
}
 
开发者ID:huashengzzz,项目名称:SmartChart,代码行数:47,代码来源:PanelListAdapter.java

示例13: onCreateView

import android.widget.TextView; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    int index = getArguments().getInt("INDEX");

    View v = inflater.inflate(R.layout.view_matrix_frag, container, false);
    CardView cardView = (CardView) v.findViewById(R.id.DynamicCardView);

    SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getContext());
    String string = sharedPreferences.getString("ELEVATE_AMOUNT", "4");
    String string2 = sharedPreferences.getString("CARD_CHANGE_KEY", "#bdbdbd");

    cardView.setCardElevation(Integer.parseInt(string));
    cardView.setCardBackgroundColor(Color.parseColor(string2));

    CardView.LayoutParams params1 = new CardView.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);

    GridLayout gridLayout = new GridLayout(getContext());
    gridLayout.setRowCount(((GlobalValues) getActivity().getApplication()).GetCompleteList().get(index).GetRow());
    gridLayout.setColumnCount(((GlobalValues) getActivity().getApplication()).GetCompleteList().get(index).GetCol());
    for (int i = 0; i < ((GlobalValues) getActivity().getApplication()).GetCompleteList().get(index).GetRow(); i++) {
        for (int j = 0; j < ((GlobalValues) getActivity().getApplication()).GetCompleteList().get(index).GetCol(); j++) {
            TextView textView = new TextView(getContext());
            textView.setGravity(Gravity.CENTER);
            textView.setText(SafeSubString(GetText(((GlobalValues) getActivity().getApplication()).GetCompleteList().get(index).GetElementof(i, j)), getLength()));
            textView.setWidth(CalculatedWidth(((GlobalValues) getActivity().getApplication()).GetCompleteList().get(index).GetCol()));
            textView.setTextSize(SizeReturner(((GlobalValues) getActivity().getApplication()).GetCompleteList().get(index).GetRow(), ((GlobalValues) getActivity().getApplication()).GetCompleteList().get(index).GetCol(),
                    PreferenceManager.getDefaultSharedPreferences(getContext()).
                            getBoolean("EXTRA_SMALL_FONT", false)));
            textView.setHeight(CalculatedHeight(((GlobalValues) getActivity().getApplication()).GetCompleteList().get(index).GetRow()));
            GridLayout.Spec Row = GridLayout.spec(i, 1);
            GridLayout.Spec Col = GridLayout.spec(j, 1);
            GridLayout.LayoutParams params = new GridLayout.LayoutParams(Row, Col);
            gridLayout.addView(textView, params);
        }
    }
    gridLayout.setLayoutParams(params1);
    cardView.addView(gridLayout);


    // Inflate the layout for this fragment
    return v;
}
 
开发者ID:coder3101,项目名称:Matrix-Calculator-for-Android,代码行数:45,代码来源:ViewMatrixFragment.java

示例14: onCreateView

import android.widget.TextView; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    final int index = getArguments().getInt("INDEX");

    View v = inflater.inflate(R.layout.view_matrix_frag, container, false);
    CardView cardView = (CardView) v.findViewById(R.id.DynamicCardView);

    SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getContext());
    String string = sharedPreferences.getString("ELEVATE_AMOUNT", "4");
    String string2 = sharedPreferences.getString("CARD_CHANGE_KEY", "#bdbdbd");

    cardView.setCardElevation(Integer.parseInt(string));
    cardView.setCardBackgroundColor(Color.parseColor(string2));

    CardView.LayoutParams params1 = new CardView.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);

    GridLayout gridLayout = new GridLayout(getContext());
    gridLayout.setRowCount(((GlobalValues) getActivity().getApplication()).GetCompleteList().get(index).GetRow());
    gridLayout.setColumnCount(((GlobalValues) getActivity().getApplication()).GetCompleteList().get(index).GetCol());
    for (int i = 0; i < ((GlobalValues) getActivity().getApplication()).GetCompleteList().get(index).GetRow(); i++) {
        for (int j = 0; j < ((GlobalValues) getActivity().getApplication()).GetCompleteList().get(index).GetCol(); j++) {
            final TextView textView = new TextView(getContext());
            textView.setGravity(Gravity.CENTER);
            textView.setTag(i * 10 + j);
            textView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    textView.setTypeface(textView.getTypeface(), Typeface.BOLD);
                    final ProgressDialog progressDialog = new ProgressDialog(getContext());
                    progressDialog.setIndeterminate(false);
                    progressDialog.setMessage(getString(R.string.Calculating));
                    progressDialog.setProgress(ProgressDialog.STYLE_SPINNER);
                    progressDialog.setTitle(getString(R.string.Calculating));
                    progressDialog.show();
                    Runnable runnable = new Runnable() {
                        @Override
                        public void run() {
                            float res = ((GlobalValues) getActivity().getApplication()).GetCompleteList().get(index).GetMinorDeterminant(((int) textView.getTag()) / 10, ((int) textView.getTag()) % 10);
                            Message message = new Message();
                            Bundle bundle = new Bundle();
                            bundle.putInt("REX", ((int) textView.getTag()) / 10);
                            bundle.putInt("REY", ((int) textView.getTag()) % 10);
                            bundle.putFloat("VALUE", res);
                            message.setData(bundle);
                            progressDialog.dismiss();
                            handler.sendMessage(message);
                        }
                    };
                    Thread thread = new Thread(runnable);
                    thread.start();
                }
            });
            textView.setText(SafeSubString(GetText(((GlobalValues) getActivity().getApplication()).GetCompleteList().get(index).GetElementof(i, j)), getLenght()));
            textView.setWidth(CalculatedWidth(((GlobalValues) getActivity().getApplication()).GetCompleteList().get(index).GetCol()));
            textView.setTextSize(SizeReturner(((GlobalValues) getActivity().getApplication()).GetCompleteList().get(index).GetRow(), ((GlobalValues) getActivity().getApplication()).GetCompleteList().get(index).GetCol(),
                    PreferenceManager.getDefaultSharedPreferences(getContext()).
                            getBoolean("EXTRA_SMALL_FONT", false)));
            textView.setHeight(CalculatedHeight(((GlobalValues) getActivity().getApplication()).GetCompleteList().get(index).GetRow()));
            GridLayout.Spec Row = GridLayout.spec(i, 1);
            GridLayout.Spec Col = GridLayout.spec(j, 1);
            GridLayout.LayoutParams params = new GridLayout.LayoutParams(Row, Col);
            gridLayout.addView(textView, params);
        }
    }
    gridLayout.setLayoutParams(params1);
    cardView.addView(gridLayout);

    // Inflate the layout for this fragment
    return v;

}
 
开发者ID:coder3101,项目名称:Matrix-Calculator-for-Android,代码行数:74,代码来源:MinorChooserFragment.java

示例15: setTabSelectedBG

import android.widget.TextView; //导入方法依赖的package包/类
private void setTabSelectedBG(TextView vLine, TextView vText) {
    vLine.setBackgroundColor(getResources().getColor(R.color.ac_filter_string_color));
    vLine.setHeight(6);
    vText.setTextColor(getResources().getColor(R.color.ac_filter_string_color));
}
 
开发者ID:LanguidSheep,项目名称:sealtalk-android-master,代码行数:6,代码来源:ReadReceiptDetailActivity.java


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