Java Code Examples for android.widget.TextView#setHeight()
The following examples show how to use
android.widget.TextView#setHeight() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SingleParallaxListView.java From UltimateAndroid with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.parallax_scroll_list_one_parallax); ParallaxListView listView = (ParallaxListView) findViewById(R.id.list_view); CustomListAdapter adapter = new CustomListAdapter(LayoutInflater.from(this)); TextView v = new TextView(this); v.setText("PARALLAXED"); v.setGravity(Gravity.CENTER); v.setTextSize(40); v.setHeight(200); v.setBackgroundResource(R.drawable.parallax_scroll_item_background); listView.addParallaxedHeaderView(v); listView.setAdapter(adapter); }
Example 2
Source File: SingleParallaxExpandableListView.java From ParallaxScroll with MIT License | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.expand_list_one_parallax); ParallaxExpandableListView listView = (ParallaxExpandableListView) findViewById(R.id.list_view); TextView v = new TextView(this); v.setText("PARALLAXED"); v.setGravity(Gravity.CENTER); v.setTextSize(40); v.setHeight(200); v.setBackgroundResource(R.drawable.item_background); listView.addParallaxedHeaderView(v); CustomExpandableListAdapter adapter = new CustomExpandableListAdapter(LayoutInflater.from(this)); listView.setAdapter(adapter); }
Example 3
Source File: SingleParallaxExpandableListView.java From UltimateAndroid with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.parallax_scroll_expand_list_one_parallax); ParallaxExpandableListView listView = (ParallaxExpandableListView) findViewById(R.id.list_view); TextView v = new TextView(this); v.setText("PARALLAXED"); v.setGravity(Gravity.CENTER); v.setTextSize(40); v.setHeight(200); v.setBackgroundResource(R.drawable.parallax_scroll_item_background); listView.addParallaxedHeaderView(v); CustomExpandableListAdapter adapter = new CustomExpandableListAdapter(LayoutInflater.from(this)); listView.setAdapter(adapter); }
Example 4
Source File: LoadingStatusAgent.java From Shield with MIT License | 6 votes |
@Override public View onCreateView(ViewGroup parent, int viewType) { LinearLayout rootView = new LinearLayout(mContext); rootView.setOrientation(LinearLayout.VERTICAL); rootView.setBackgroundColor(getContext().getResources().getColor(android.R.color.white)); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); params.leftMargin = ViewUtils.dip2px(getContext(), 30); itemViewHolder = new ItemViewHolder(); TextView textView = new TextView(mContext); textView.setHeight(ViewUtils.dip2px(getContext(), 50)); textView.setGravity(Gravity.CENTER_VERTICAL); itemViewHolder.textView = textView; rootView.addView(textView, params); rootView.setTag(itemViewHolder); return rootView; }
Example 5
Source File: LoadingBaseCell.java From Shield with MIT License | 6 votes |
@Override public View loadingMoreFailedView() { LinearLayout rootView = (LinearLayout) getRootView(); TextView textView = new TextView(mContext); textView.setHeight(ViewUtils.dip2px(getContext(), 50)); textView.setText("loadingmore fail: 点击重新加载"); textView.setGravity(Gravity.CENTER); textView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (mLoadingMoreRetryListener != null) { mLoadingMoreRetryListener.onClick(v); } } }); rootView.addView(textView); return rootView; }
Example 6
Source File: LoadingBaseCell.java From Shield with MIT License | 6 votes |
@Override public View loadingMoreView() { LinearLayout rootView = (LinearLayout) getRootView(); TextView textView = new TextView(mContext); textView.setHeight(ViewUtils.dip2px(getContext(), 50)); textView.setText("loadingmore: 正在载入"); textView.setGravity(Gravity.CENTER); textView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (mResetOnClickListener != null) { mResetOnClickListener.onClick(v); } } }); rootView.addView(textView); return rootView; }
Example 7
Source File: DefaultDividerAgent.java From Shield with MIT License | 6 votes |
private View createShowView() { LinearLayout rootView = new LinearLayout(mContext); rootView.setOrientation(LinearLayout.VERTICAL); rootView.setLayoutParams(new ViewGroup.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)); rootView.setBackgroundColor(getContext().getResources().getColor(android.R.color.white)); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); params.leftMargin = ViewUtils.dip2px(getContext(), 30); ItemViewHolder itemViewHolder = new ItemViewHolder(); TextView textView = new TextView(mContext); textView.setHeight(ViewUtils.dip2px(getContext(), 50)); textView.setGravity(Gravity.CENTER_VERTICAL); itemViewHolder.textView = textView; rootView.addView(textView, params); rootView.setTag(itemViewHolder); return rootView; }
Example 8
Source File: SingleParallaxListView.java From UltimateAndroid with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.parallax_scroll_list_one_parallax); ParallaxListView listView = (ParallaxListView) findViewById(R.id.list_view); CustomListAdapter adapter = new CustomListAdapter(LayoutInflater.from(this)); TextView v = new TextView(this); v.setText("PARALLAXED"); v.setGravity(Gravity.CENTER); v.setTextSize(40); v.setHeight(200); v.setBackgroundResource(R.drawable.parallax_scroll_item_background); listView.addParallaxedHeaderView(v); listView.setAdapter(adapter); }
Example 9
Source File: LoadingBaseCell.java From Shield with MIT License | 6 votes |
@Override public View loadingView() { LinearLayout rootView = (LinearLayout) getRootView(); TextView textView = new TextView(mContext); textView.setHeight(ViewUtils.dip2px(getContext(), 50)); textView.setText("loading: 加载中"); textView.setGravity(Gravity.CENTER); textView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (mResetOnClickListener != null) { mResetOnClickListener.onClick(v); } } }); rootView.addView(textView); return rootView; }
Example 10
Source File: LiteSyllabusView.java From LiteSyllabusView with Apache License 2.0 | 6 votes |
private void setupSectionSidebar() { layoutSectionSidebar = new LinearLayout(mContext); layoutSectionSidebar.setOrientation(VERTICAL); ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(mSectionSidebarWidth, ViewGroup.LayoutParams.MATCH_PARENT); layoutSectionSidebar.setLayoutParams(params); for (int i = 1; i <= mSectionNumber; ++i) { layoutSectionSidebar.addView(getHorizontalDividerView()); TextView tvSectionNumberTitle = new TextView(mContext); tvSectionNumberTitle.setWidth(mSectionSidebarWidth); tvSectionNumberTitle.setHeight(mSectionHeight); tvSectionNumberTitle.setText("" + i); tvSectionNumberTitle.setTextSize(SECTION_SIDEBAR_TEXT_SIZE); tvSectionNumberTitle.setTextColor(ContextCompat.getColor(mContext, R.color.textTitle)); tvSectionNumberTitle.setGravity(Gravity.CENTER); tvSectionNumberTitle.setTypeface(mTitleTypeface); layoutSectionSidebar.addView(tvSectionNumberTitle); } layoutSectionSidebar.setBackgroundColor(ContextCompat.getColor(mContext, R.color.bgSectionSidbar)); }
Example 11
Source File: SingleParallaxListView.java From ParallaxScroll with MIT License | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.list_one_parallax); ParallaxListView listView = (ParallaxListView) findViewById(R.id.list_view); CustomListAdapter adapter = new CustomListAdapter(LayoutInflater.from(this)); TextView v = new TextView(this); v.setText("PARALLAXED"); v.setGravity(Gravity.CENTER); v.setTextSize(40); v.setHeight(200); v.setBackgroundResource(R.drawable.item_background); listView.addParallaxedHeaderView(v); listView.setAdapter(adapter); }
Example 12
Source File: CustomPlaybackOverlayFragment.java From jellyfin-androidtv with GNU General Public License v2.0 | 6 votes |
@Override protected void onPostExecute(Void aVoid) { Timber.d("*** Display programs post execute"); if (mCurrentDisplayChannelEndNdx < mAllChannels.size() - 1) { // Show a paging row for channels below int pageDnEnd = mCurrentDisplayChannelEndNdx + PAGE_SIZE; if (pageDnEnd >= mAllChannels.size()) pageDnEnd = mAllChannels.size() - 1; TextView placeHolder = new TextView(mActivity); placeHolder.setHeight(LiveTvGuideActivity.PAGEBUTTON_HEIGHT); mChannels.addView(placeHolder); mProgramRows.addView(new GuidePagingButton(mActivity, mFragment, mCurrentDisplayChannelEndNdx + 1, getString(R.string.lbl_load_channels) + mAllChannels.get(mCurrentDisplayChannelEndNdx + 1).getNumber() + " - " + mAllChannels.get(pageDnEnd).getNumber())); } mChannelStatus.setText(displayedChannels + " of " + mAllChannels.size() + " channels"); mFilterStatus.setText(" for next " + mGuideHours + " hours"); mFilterStatus.setTextColor(Color.GRAY); mGuideSpinner.setVisibility(View.GONE); if (firstRow != null) firstRow.requestFocus(); }
Example 13
Source File: ViewSwitcherWrapper.java From Android-Notification with Apache License 2.0 | 6 votes |
private void adjustTextViewHeight() { View view = getView(); if (view == null) { return; } TextSwitcher textSwitcher = (TextSwitcher) view; TextView curr = (TextView) textSwitcher.getCurrentView(); TextView next = (TextView) textSwitcher.getNextView(); int currH = curr.getLineCount() * curr.getLineHeight(); int nextH = next.getLineCount() * next.getLineHeight(); if (currH != nextH) { curr.setHeight(currH); next.setHeight(currH); } }
Example 14
Source File: LiteSyllabusView.java From LiteSyllabusView with Apache License 2.0 | 5 votes |
private void setupWeekdayHeader() { layoutWeekdayHeader = new LinearLayout(mContext); layoutWeekdayHeader.setOrientation(HORIZONTAL); ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, mWeekdayHeaderHeight); layoutWeekdayHeader.setLayoutParams(params); TextView tvEmptyCellOnTopAndLeft = new TextView(mContext); tvEmptyCellOnTopAndLeft.setWidth(mSectionSidebarWidth); tvEmptyCellOnTopAndLeft.setHeight(mWeekdayHeaderHeight); tvEmptyCellOnTopAndLeft.setText("\\"); tvEmptyCellOnTopAndLeft.setTextSize(WEEKDAY_TITLE_TEXT_SIZE); tvEmptyCellOnTopAndLeft.setTextColor(ContextCompat.getColor(mContext, R.color.textTitle)); tvEmptyCellOnTopAndLeft.setGravity(Gravity.CENTER); tvEmptyCellOnTopAndLeft.setTypeface(mTitleTypeface); layoutWeekdayHeader.addView(tvEmptyCellOnTopAndLeft); for (int i = 0; i < mWeekdayNumber; ++i) { layoutWeekdayHeader.addView(getVerticalDividerView()); TextView tvWeekdayTitle = new TextView(mContext); tvWeekdayTitle.setWidth(mSectionWidth); tvWeekdayTitle.setHeight(mWeekdayHeaderHeight); tvWeekdayTitle.setText(WEEKDAY_TITLES[i]); tvWeekdayTitle.setTextSize(WEEKDAY_TITLE_TEXT_SIZE); tvWeekdayTitle.setTextColor(ContextCompat.getColor(mContext, R.color.textTitle)); tvWeekdayTitle.setGravity(Gravity.CENTER); tvWeekdayTitle.setTypeface(mTitleTypeface); layoutWeekdayHeader.addView(tvWeekdayTitle); } layoutWeekdayHeader.setBackgroundColor(ContextCompat.getColor(mContext, R.color.bgWeekdayHeader)); }
Example 15
Source File: PluginSettingsAdapter.java From xposed-rimet with Apache License 2.0 | 5 votes |
public View onCreateView(LayoutInflater layoutInflater, ViewGroup parent, int viewType) { CommentItemView commentItemView = new CommentItemView(getContext()); TextView textView = commentItemView.getContentView(); textView.setTextSize(16); textView.setMinLines(1); textView.setMaxLines(1); textView.setHeight(DisplayUtil.dip2px(getContext(), 32)); return commentItemView; }
Example 16
Source File: ScheduleView.java From SmallGdufe-Android with GNU General Public License v3.0 | 5 votes |
/** * 横的分界线 * * @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; }
Example 17
Source File: TickAdapter.java From tickmate with GNU General Public License v3.0 | 5 votes |
/** * Used to create and insert the week separator * * @param tickGrid the ViewGroup into which the week separator will be inserted */ private void addStartWeekSeparator(ViewGroup tickGrid) { TextView splitter2 = new TextView(this.context); splitter2.setText(""); splitter2.setHeight(5); tickGrid.addView(splitter2); TextView splitter = new TextView(this.context); splitter.setText(""); splitter.setHeight(11); splitter.setBackgroundResource(R.drawable.center_line); splitter.setPadding(0, 20, 0, 0); tickGrid.addView(splitter); }
Example 18
Source File: LoadingStatusMoreAgent.java From Shield with MIT License | 5 votes |
@Override public View onCreateView(ViewGroup parent, int viewType) { LinearLayout rootView = new LinearLayout(mContext); rootView.setLayoutParams(new ViewGroup.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); rootView.setOrientation(LinearLayout.VERTICAL); rootView.setBackgroundColor(getContext().getResources().getColor(android.R.color.white)); if (viewType == 0) { View containView = LayoutInflater.from(getContext()).inflate(R.layout.agent_status_loading_more, rootView, false); setLoadingStatus(containView); rootView.addView(containView); } else { LinearLayout.LayoutParams params = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); params.setMargins(ViewUtils.dip2px(getContext(), 30), 0, 0, 0); itemViewHolder = new ItemViewHolder(); TextView textView = new TextView(mContext); textView.setHeight(ViewUtils.dip2px(getContext(), 50)); textView.setGravity(Gravity.CENTER_VERTICAL); itemViewHolder.textView = textView; rootView.addView(textView, params); rootView.setTag(itemViewHolder); } return rootView; }
Example 19
Source File: StringPresenter.java From VCL-Android with Apache License 2.0 | 5 votes |
public void onBindViewHolder(ViewHolder viewHolder, Object item) { Resources res = viewHolder.view.getContext().getResources(); TextView tv = (TextView) viewHolder.view; tv.setText(item.toString()); if (res.getString(R.string.preferences).equals(item.toString())) { tv.setBackground(res.getDrawable(R.drawable.ic_menu_preferences_big)); } tv.setHeight(res.getDimensionPixelSize(R.dimen.grid_card_thumb_height)); tv.setWidth(res.getDimensionPixelSize(R.dimen.grid_card_thumb_width)); }
Example 20
Source File: PanelListAdapter.java From SmartChart with Apache License 2.0 | 4 votes |
/** * 初始化横向表头的布局,必须在所有的布局都载入完之后才能调用 * <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); } } }