本文整理匯總了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;
}
示例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;
}
示例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;
}
示例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();
}
示例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();
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
}
示例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);
}
示例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);
}
}
}
示例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;
}
示例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;
}
示例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));
}