本文整理了Java中android.widget.TextView.setHeight()
方法的一些代码示例,展示了TextView.setHeight()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TextView.setHeight()
方法的具体详情如下:
包路径:android.widget.TextView
类名称:TextView
方法名:setHeight
暂无
代码示例来源:origin: stackoverflow.com
private void addTableRow() {
final TableLayout table = (TableLayout) findViewById(R.id.my_table);
final TableRow tr = (TableRow) getLayoutInflater().inflate(R.layout.table_row_item, null);
TextView tv;
// Fill out our cells
tv = (TextView) tr.findViewById(R.id.cell_1);
tv.setText(...);
...
tv = (TextView) tr.findViewById(R.id.cell_N);
tv.setText(...);
table.addView(tr);
// Draw separator
tv = new TextView(this);
tv.setBackgroundColor(Color.parseColor("#80808080"));
tv.setHeight(/*height of separaor line. 2dip will be enough*/);
table.addView(tv);
// If you use context menu it should be registered for each table row
registerForContextMenu(tr);
}
代码示例来源:origin: H07000223/FlycoDialog_Master
tvItem.setTextColor(mItemTextColor);
tvItem.setTextSize(TypedValue.COMPLEX_UNIT_SP, mItemTextSize);
tvItem.setHeight(dp2px(mItemHeight));
代码示例来源:origin: H07000223/FlycoDialog_Master
mTvTitle.setHeight(dp2px(mTitleHeight));
mTvTitle.setBackgroundDrawable(CornerUtils.cornerDrawable(mTitleBgColor, new float[]{radius, radius, radius,
radius, 0, 0, 0, 0}));
mTvCancel.setHeight(dp2px(mItemHeight));
mTvCancel.setText(mCancelText);
mTvCancel.setTextSize(TypedValue.COMPLEX_UNIT_SP, mCancelTextSize);
代码示例来源:origin: rey5137/material
v.setHeight(a.getDimensionPixelSize(attr, -1));
代码示例来源:origin: stackoverflow.com
TextView tv = (TextView) findViewById(R.id.TextView02);
int height_in_pixels = tv.getLineCount() * tv.getLineHeight(); //approx height text
tv.setHeight(height_in_pixels);
代码示例来源:origin: stackoverflow.com
for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) {
Tab tab = actionBar.newTab();
TextView customTabView = (TextView)getLayoutInflater().inflate(R.layout.custom_tab, null);
customTabView.setText(mSectionsPagerAdapter.getPageTitle(i));
// set the height to a really high value to fill the parent
customTabView.setHeight(999);
tab.setCustomView(customTabView);
tab.setTabListener(this);
actionBar.addTab(tab);
}
代码示例来源:origin: stackoverflow.com
@Override
public View getDropDownView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
TextView textview = (TextView)inflater.inflate(android.R.layout.simple_spinner_item, null);
textview.setText(alOpcion.get(position).getOpcionName());
DisplayMetrics metrics = parent.getResources().getDisplayMetrics();
float dp = 40f;
float fpixels = metrics.density * dp;
int pixels = (int) (fpixels + 0.5f);
textview.setHeight(pixels);
return textview;
}
代码示例来源:origin: zsoltk/GameOfLife
@NonNull
protected View createHiddenView() {
TextView hidden = new TextView(context);
hidden.setHeight(0);
hidden.setVisibility(View.GONE);
return hidden;
}
代码示例来源:origin: stackoverflow.com
convertView.setMinimumHeight(parent.getMeasuredHeight());
ImageView slika=(ImageView)v.findViewById(R.id.imageView_obj);
slika.setMinimumHeight(parent.getMeasuredHeight());
TextView xx=(TextView)v.findViewById(R.id.xx);
xx.setHeight(parent.getMeasuredHeight());
代码示例来源:origin: stackoverflow.com
TextView headerTextView = new TextView(this.context);
float scale = context.getResources().getDisplayMetrics().density;
if(scale > 2.0) {
headerTextView.setWidth(210);
headerTextView.setHeight(120);
headerTextView.setTextSize(17);
}
else {
headerTextView.setWidth(125);
headerTextView.setHeight(60);
headerTextView.setTextSize(21);
}
代码示例来源:origin: stackoverflow.com
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View view = super.getView(position, convertView, parent);
TextView textView = (TextView) view.findViewById(android.R.id.text1);
textView.setHeight(30);
textView.setMinimumHeight(30);
/*YOUR CHOICE OF COLOR*/
textView.setTextColor(Color.BLACK);
return view;
}
代码示例来源:origin: stackoverflow.com
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TextView myTextView = new TextView(this);
myTextView.setText("Marsha Jackson - (555) 555-5555 - marsha.jackson@email.com - www.jkl.com");
myTextView.setWidth(100);
myTextView.setHeight(500);
//you can keep adding code to change myTextView
setContentView(myTextView);
}
代码示例来源:origin: mylhyl/Android-CircleDialog
private void handleNeutralStyle() {
mNeutralButton.setGravity(Gravity.CENTER);
mNeutralButton.setText(mNeutralParams.text);
mNeutralButton.setEnabled(!mNeutralParams.disable);
mNeutralButton.setTextColor(mNeutralParams.disable ?
mNeutralParams.textColorDisable : mNeutralParams.textColor);
mNeutralButton.setTextSize(mNeutralParams.textSize);
mNeutralButton.setHeight(mNeutralParams.height);
mNeutralButton.setTypeface(mNeutralButton.getTypeface(), mNeutralParams.styleText);
}
代码示例来源:origin: mylhyl/Android-CircleDialog
private void handleNeutralStyle() {
mNeutralButton.setGravity(Gravity.CENTER);
mNeutralButton.setText(mNeutralParams.text);
mNeutralButton.setEnabled(!mNeutralParams.disable);
mNeutralButton.setTextColor(mNeutralParams.disable ?
mNeutralParams.textColorDisable : mNeutralParams.textColor);
mNeutralButton.setTextSize(mNeutralParams.textSize);
mNeutralButton.setHeight(mNeutralParams.height);
mNeutralButton.setTypeface(mNeutralButton.getTypeface(), mNeutralParams.styleText);
}
代码示例来源:origin: mylhyl/Android-CircleDialog
private void handleNegativeStyle() {
mNegativeButton.setGravity(Gravity.CENTER);
mNegativeButton.setText(mNegativeParams.text);
mNegativeButton.setEnabled(!mNegativeParams.disable);
mNegativeButton.setTextColor(mNegativeParams.disable ?
mNegativeParams.textColorDisable : mNegativeParams.textColor);
mNegativeButton.setTextSize(mNegativeParams.textSize);
mNegativeButton.setHeight(mNegativeParams.height);
mNegativeButton.setTypeface(mNegativeButton.getTypeface(), mNegativeParams.styleText);
}
代码示例来源:origin: mylhyl/Android-CircleDialog
private void handlePositiveStyle() {
mPositiveButton.setGravity(Gravity.CENTER);
mPositiveButton.setText(mPositiveParams.text);
mPositiveButton.setEnabled(!mPositiveParams.disable);
mPositiveButton.setTextColor(mPositiveParams.disable ?
mPositiveParams.textColorDisable : mPositiveParams.textColor);
mPositiveButton.setTextSize(mPositiveParams.textSize);
mPositiveButton.setHeight(mPositiveParams.height);
mPositiveButton.setTypeface(mPositiveButton.getTypeface(), mPositiveParams.styleText);
}
代码示例来源:origin: mylhyl/Android-CircleDialog
private void handleNegativeStyle() {
mNegativeButton.setGravity(Gravity.CENTER);
mNegativeButton.setText(mNegativeParams.text);
mNegativeButton.setEnabled(!mNegativeParams.disable);
mNegativeButton.setTextColor(mNegativeParams.disable ?
mNegativeParams.textColorDisable : mNegativeParams.textColor);
mNegativeButton.setTextSize(mNegativeParams.textSize);
mNegativeButton.setHeight(mNegativeParams.height);
mNegativeButton.setTypeface(mNegativeButton.getTypeface(), mNegativeParams.styleText);
}
代码示例来源:origin: mylhyl/Android-CircleDialog
private void handlePositiveStyle() {
mPositiveButton.setGravity(Gravity.CENTER);
mPositiveButton.setText(mPositiveParams.text);
mPositiveButton.setEnabled(!mPositiveParams.disable);
mPositiveButton.setTextColor(mPositiveParams.disable ?
mPositiveParams.textColorDisable : mPositiveParams.textColor);
mPositiveButton.setTextSize(mPositiveParams.textSize);
mPositiveButton.setHeight(mPositiveParams.height);
mPositiveButton.setTypeface(mPositiveButton.getTypeface(), mPositiveParams.styleText);
}
代码示例来源:origin: stackoverflow.com
ListView lvLogs = new ListView(this);
lvLogs.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, logs) {
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View view = super.getView(position, convertView, parent);
TextView textView = ((TextView) view.findViewById(android.R.id.text1));
textView.setMinHeight(0); // Min Height
textView.setMinimumHeight(0); // Min Height
textView.setHeight(44); // Height
return view;
}
});
代码示例来源:origin: stackoverflow.com
public static void expandCollapsedByMaxLines(@NonNull final TextView text) {
final int height = text.getMeasuredHeight();
text.setHeight(height);
text.setMaxLines(Integer.MAX_VALUE); //expand fully
text.measure(View.MeasureSpec.makeMeasureSpec(text.getMeasuredWidth(), View.MeasureSpec.EXACTLY), View.MeasureSpec.makeMeasureSpec(ViewGroup.LayoutParams.WRAP_CONTENT, View.MeasureSpec.UNSPECIFIED));
final int newHeight = text.getMeasuredHeight();
ObjectAnimator animation = ObjectAnimator.ofInt(text, "height", height, newHeight);
animation.setDuration(250).start();
}
内容来源于网络,如有侵权,请联系作者删除!