List of usage examples for android.widget TextView setHeight
@android.view.RemotableViewMethod public void setHeight(int pixels)
pixels
tall. From source file:com.softminds.matrixcalculator.base_fragments.ViewMatrixFragment.java
@Override public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { int index = getArguments().getInt("INDEX"); View v = inflater.inflate(R.layout.view_matrix_frag, container, false); 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)); final int border = getResources().getDimensionPixelOffset(R.dimen.border_width); CardView.LayoutParams params1 = new CardView.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); cardView.setUseCompatPadding(true);/*from w w w . ja v a 2 s. co m*/ GridLayout gridLayout = new GridLayout(getContext()); int rows = ((GlobalValues) getActivity().getApplication()).GetCompleteList().get(index).getNumberOfRows(); int cols = ((GlobalValues) getActivity().getApplication()).GetCompleteList().get(index).getNumberOfCols(); gridLayout.setRowCount(rows); gridLayout.setColumnCount(cols); for (int i = 0; i < rows; i++) { for (int j = 0; j < cols; j++) { TextView textView = new TextView(getContext()); textView.setGravity(Gravity.CENTER); textView.setBackgroundColor(Color.parseColor(string2)); textView.setText(SafeSubString(GetText(((GlobalValues) getActivity().getApplication()) .GetCompleteList().get(index).getElementOf(i, j)), getLength())); textView.setWidth(CalculatedWidth(cols)); textView.setTextSize(SizeReturner(rows, cols, PreferenceManager .getDefaultSharedPreferences(getContext()).getBoolean("EXTRA_SMALL_FONT", false))); textView.setHeight(CalculatedHeight(rows)); GridLayout.Spec Row = GridLayout.spec(i, 1); GridLayout.Spec Col = GridLayout.spec(j, 1); GridLayout.LayoutParams params = new GridLayout.LayoutParams(Row, Col); params.leftMargin = params.topMargin = params.bottomMargin = params.rightMargin = border; gridLayout.addView(textView, params); } } gridLayout.setLayoutParams(params1); cardView.addView(gridLayout); // Inflate the layout for this fragment return v; }
From source file:edu.cens.loci.ui.PlaceViewActivity.java
private void updateWifiList(TableLayout table, LociWifiFingerprint wifi) { ArrayList<WifiViewListItem> items = new ArrayList<WifiViewListItem>(); HashMap<String, APInfoMapItem> apMap = wifi.getAps(); Set<String> keys = apMap.keySet(); Iterator<String> iter = keys.iterator(); while (iter.hasNext()) { String bssid = iter.next(); APInfoMapItem ap = apMap.get(bssid); items.add(new WifiViewListItem(bssid, ap.ssid, ap.rss, ap.count, ap.rssBuckets)); }// w ww . j av a 2s . c om Collections.sort(items); table.setColumnCollapsed(0, false); table.setColumnCollapsed(1, true); table.setColumnShrinkable(0, true); for (int i = 0; i < mAddedRows.size(); i++) { table.removeView(mAddedRows.get(i)); } mAddedRows.clear(); int totalCount = wifi.getScanCount(); for (WifiViewListItem item : items) { TableRow row = new TableRow(this); TextView ssidView = new TextView(this); ssidView.setText(item.ssid); //ssidView.setText("very very very veryvery very very very very very"); ssidView.setPadding(2, 2, 2, 2); ssidView.setTextColor(0xffffffff); TextView bssidView = new TextView(this); bssidView.setText(item.bssid); bssidView.setPadding(2, 2, 2, 2); bssidView.setTextColor(0xffffffff); TextView cntView = new TextView(this); cntView.setText("" + (item.count * 100) / totalCount); cntView.setPadding(2, 2, 2, 2); cntView.setGravity(Gravity.CENTER); cntView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12); TextView rssView = new TextView(this); rssView.setText("" + item.rss); rssView.setPadding(2, 2, 6, 2); rssView.setGravity(Gravity.CENTER); rssView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12); row.addView(ssidView, new TableRow.LayoutParams(0)); row.addView(bssidView, new TableRow.LayoutParams(1)); row.addView(cntView, new TableRow.LayoutParams(2)); row.addView(rssView, new TableRow.LayoutParams(3)); //Log.d(TAG, item.ssid); for (int i = 0; i < item.rssBuckets.length; i++) { TextView box = new TextView(this); box.setText(" "); box.setGravity(Gravity.RIGHT); box.setPadding(2, 2, 2, 2); box.setHeight(15); box.setGravity(Gravity.CENTER_VERTICAL); float colorVal = 256 * ((float) item.rssBuckets[i] / (float) wifi.getScanCount()); //Log.d(TAG, "colorVal=" + (int) colorVal + ", " + item.histogram[i]); int colorValInt = ((int) colorVal) - 1; if (colorValInt < 0) colorValInt = 0; box.setBackgroundColor(0xff000000 + colorValInt);//+ 0x000000ff * (item.histogram[i]/totScan)); box.setTextColor(0xffffffff); row.addView(box, new TableRow.LayoutParams(4 + i)); } row.setGravity(Gravity.CENTER); table.addView(row, new TableLayout.LayoutParams()); table.setColumnStretchable(3, true); mAddedRows.add(row); } }
From source file:org.cvasilak.jboss.mobile.app.fragments.ProfileViewFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); // adjust the title ActionBar bar = ((ActionBarActivity) getActivity()).getSupportActionBar(); if (path == null) bar.setTitle(application.getOperationsManager().getServer().getName()); else/*from w w w.ja v a 2s.c o m*/ bar.setTitle(path.get(path.size() - 1)); MergeAdapter adapter = new MergeAdapter(); TextView sectionHeader; // Section: Attributes sectionHeader = new TextView(getActivity()); sectionHeader.setBackgroundColor(Color.DKGRAY); sectionHeader.setPadding(15, 10, 0, 10); sectionHeader.setText(R.string.attributes); adapter.addView(sectionHeader); adapter.addAdapter(new AttributeAdapter(attributes)); // Section ChildTypes sectionHeader = new TextView(getActivity()); sectionHeader.setBackgroundColor(Color.DKGRAY); sectionHeader.setPadding(15, 10, 0, 10); sectionHeader.setText(R.string.child_types); adapter.addView(sectionHeader); adapter.addAdapter(new ChildTypeAdapter(childTypes)); // Section Operations sectionHeader = new TextView(getActivity()); sectionHeader.setBackgroundColor(Color.DKGRAY); sectionHeader.setHeight(20); sectionHeader.setPadding(15, 10, 0, 10); adapter.addView(sectionHeader); adapter.addAdapter(new IconTextRowAdapter(getActivity(), Arrays.asList(getString(R.string.operations)), R.drawable.ic_operations)); setListAdapter(adapter); }
From source file:com.mydatingapp.ui.base.SkBaseInnerActivity.java
public void setActionBarLogoCounter(int count) { ImageView logo = (ImageView) findViewById(android.R.id.home); if (count < 1) { currentLogoCounter = 0;/*from w w w.ja va2 s .c om*/ logo.setVisibility(View.GONE); return; } else { logo.setVisibility(View.VISIBLE); } currentLogoCounter = count; TextView v = new TextView(getApp()); v.setText(new Integer(count).toString()); v.setBackgroundResource(R.drawable.sidebar_menu_counterbg); v.setTextSize(TypedValue.COMPLEX_UNIT_SP, 15); v.setDrawingCacheEnabled(true); v.setTextColor(Color.WHITE); v.setPadding(SKDimensions.convertDpToPixel(6, getApp()), 0, SKDimensions.convertDpToPixel(6, getApp()), 0); ActionBar.LayoutParams paramsExample = new ActionBar.LayoutParams(ActionBar.LayoutParams.WRAP_CONTENT, ActionBar.LayoutParams.WRAP_CONTENT, 1); paramsExample.setMargins(0, 0, 0, 0); v.setHeight(SKDimensions.convertDpToPixel(20, getApp())); v.setLayoutParams(paramsExample); // this is the important code :) // Without it the view will have a dimension of 0,0 and the bitmap will be null v.measure(View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED), View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED)); v.layout(0, 0, v.getMeasuredWidth(), v.getMeasuredHeight()); v.buildDrawingCache(true); Bitmap b = Bitmap.createBitmap(v.getDrawingCache()); v.setDrawingCacheEnabled(false); logo.setImageDrawable(new BitmapDrawable(getApp().getResources(), b)); logo.setPadding(SKDimensions.convertDpToPixel(3, getApp()), 0, 0, 0); }
From source file:com.uni.feedee.tabs.SlidingTabLayout.java
/** * Create a default view to be used for tabs. This is called if a custom tab view is not set via * {@link #setCustomTabView(int, int)}.//from w w w . j a va 2 s . c om */ protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); textView.setTypeface(Typeface.DEFAULT_BOLD); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { // If we're running on Honeycomb or newer, then we can use the Theme's // selectableItemBackground to ensure that the View has a pressed state TypedValue outValue = new TypedValue(); getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true); textView.setBackgroundResource(outValue.resourceId); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { // If we're running on ICS or newer, enable all-caps to match the Action Bar tab style textView.setAllCaps(true); } int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(padding * 2, padding, padding * 2, padding); textView.setHeight((int) (56 * getResources().getDisplayMetrics().density)); return textView; }
From source file:com.example.paco.app.SlidingTabLayout.java
private void populateTabStrip() { final ViewPagerAdapter adapter = (ViewPagerAdapter) mViewPager.getAdapter(); final OnClickListener tabClickListener = new TabClickListener(); for (int i = 0; i < adapter.getCount(); i++) { View tabView = null;/* w w w . j a v a 2 s . co m*/ TextView tabTitleView = null; if (mTabViewLayoutId != 0) { // If there is a custom tab view layout id set, try and inflate it tabView = LayoutInflater.from(getContext()).inflate(mTabViewLayoutId, mTabStrip, false); tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId); } if (tabView == null) { tabView = createDefaultTabView(getContext()); } if (tabTitleView == null && TextView.class.isInstance(tabView)) { tabTitleView = (TextView) tabView; } if (mDistributeEvenly) { LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) tabView.getLayoutParams(); lp.width = 0; lp.weight = 1; } //Set icon, that can be changeable instead setting text. //I think the text also can setting here from getPageTitle func. //But we interesting only in icon tabTitleView.setCompoundDrawablesWithIntrinsicBounds(0, adapter.getDrawableId(i), 0, 0); tabTitleView.setHeight(215); //Select tab if it is current if (mViewPager.getCurrentItem() == i) { tabView.setSelected(true); } tabView.setOnClickListener(tabClickListener); //tabTitleView.setText(adapter.getPageTitle(i)); //tabView.setOnClickListener(tabClickListener); //String desc = mContentDescriptions.get(i, null); //if (desc != null) { // tabView.setContentDescription(desc); //} mTabStrip.addView(tabView); if (i == mViewPager.getCurrentItem()) { tabView.setSelected(true); } } }
From source file:com.myapp.smartadvisingapp.SlidingTabLayout.java
private void populateTabStrip() { final ViewPagerAdapter adapter = (ViewPagerAdapter) mViewPager.getAdapter(); final View.OnClickListener tabClickListener = new TabClickListener(); for (int i = 0; i < adapter.getCount(); i++) { View tabView = null;/*from w w w .j a va 2s .c o m*/ TextView tabTitleView = null; if (mTabViewLayoutId != 0) { // If there is a custom tab view layout id set, try and inflate it tabView = LayoutInflater.from(getContext()).inflate(mTabViewLayoutId, mTabStrip, false); tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId); } if (tabView == null) { tabView = createDefaultTabView(getContext()); } if (tabTitleView == null && TextView.class.isInstance(tabView)) { tabTitleView = (TextView) tabView; } if (mDistributeEvenly) { LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) tabView.getLayoutParams(); lp.width = 0; lp.weight = 1; } //Set icon, that can be changeable instead setting text. //I think the text also can setting here from getPageTitle func. //But we interesting only in icon tabTitleView.setCompoundDrawablesWithIntrinsicBounds(0, adapter.getDrawableId(i), 0, 0); tabTitleView.setHeight(215); //Select tab if it is current if (mViewPager.getCurrentItem() == i) { tabView.setSelected(true); } tabView.setOnClickListener(tabClickListener); //tabTitleView.setText(adapter.getPageTitle(i)); //tabView.setOnClickListener(tabClickListener); //String desc = mContentDescriptions.get(i, null); //if (desc != null) { // tabView.setContentDescription(desc); //} mTabStrip.addView(tabView); if (i == mViewPager.getCurrentItem()) { tabView.setSelected(true); } } }
From source file:net.bible.android.view.util.widget.BookmarkStyleAdapterHelper.java
public void styleView(TextView view, BookmarkStyle bookmarkStyle, Context context, boolean overrideText, boolean centreText) { // prepare text to be shown String baseText;/*w ww . j a v a2 s. co m*/ if (overrideText) { baseText = sampleText; } else { baseText = view.getText().toString(); // avoid multiple *'s if (baseText.startsWith("*")) { StringUtils.strip(baseText, "*"); } } int backgroundColor = Color.WHITE; switch (bookmarkStyle) { case YELLOW_STAR: backgroundColor = UiUtils.getThemeBackgroundColour(context); view.setTextColor(UiUtils.getThemeTextColour(context)); CharSequence imgText = addImageAtStart("* " + baseText, R.drawable.goldstar16x16, context); view.setText(imgText, TextView.BufferType.SPANNABLE); break; case RED_HIGHLIGHT: backgroundColor = BookmarkStyle.RED_HIGHLIGHT.getBackgroundColor(); view.setText(baseText); break; case YELLOW_HIGHLIGHT: backgroundColor = BookmarkStyle.YELLOW_HIGHLIGHT.getBackgroundColor(); view.setText(baseText); break; case GREEN_HIGHLIGHT: backgroundColor = BookmarkStyle.GREEN_HIGHLIGHT.getBackgroundColor(); view.setText(baseText); break; case BLUE_HIGHLIGHT: backgroundColor = BookmarkStyle.BLUE_HIGHLIGHT.getBackgroundColor(); view.setText(baseText); break; } view.setBackgroundColor(backgroundColor); view.setHeight(CommonUtils.convertDipsToPx(30)); if (centreText) { view.setGravity(Gravity.CENTER); } }
From source file:com.github.kanata3249.ffxieq.android.AugmentSelectorActivity.java
@Override protected void onStart() { super.onStart(); AugmentListView lv;//from w w w. ja v a 2 s . co m lv = (AugmentListView) findViewById(R.id.ListView); if (lv != null) { lv.setFilterByID(mFilterID); lv.setOrderByName(mOrderByName); lv.setFilterByType(mFilterByType); lv.setParam(getDAO(), mPart, mRace, mJob, mLevel); lv.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { Intent result = new Intent(); result.putExtra("From", "AugmentSelector"); result.putExtra("Part", mPart); result.putExtra("Id", -1); result.putExtra("AugId", arg3); setResult(RESULT_OK, result); finish(); } }); lv.setOnItemLongClickListener(new OnItemLongClickListener() { public boolean onItemLongClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { mLongClickingItemId = arg3; AugmentSelectorActivity.this.openContextMenu(arg0); return true; } }); registerForContextMenu(lv); } { Equipment cur = getDAO().instantiateEquipment(mCurrent, mAugID); if (cur == null) { cur = new Equipment(-1, getString(R.string.EquipmentNotSelected), "", "", "", "", 0, 0, false, false, ""); } if (cur != null) { TextView tv; View.OnLongClickListener listener = new View.OnLongClickListener() { public boolean onLongClick(View v) { mLongClickingItemId = mAugID; AugmentSelectorActivity.this.openContextMenu(v); return true; } }; tv = (TextView) findViewById(R.id.Name); if (tv != null) { tv.setText(cur.getName()); tv.setOnLongClickListener(listener); registerForContextMenu(tv); } tv = (TextView) findViewById(R.id.Job); if (tv != null) { tv.setText(cur.getJob()); tv.setOnLongClickListener(listener); registerForContextMenu(tv); } tv = (TextView) findViewById(R.id.Description); if (tv != null) { tv.setText(cur.getDescription()); tv.setOnLongClickListener(listener); registerForContextMenu(tv); } tv = (TextView) findViewById(R.id.Augment); if (tv != null) { if (cur.getAugment().length() == 0) { tv.setHeight(0); } else { tv.setText(cur.getAugment()); } tv.setOnLongClickListener(listener); registerForContextMenu(tv); } tv = (TextView) findViewById(R.id.Level); if (tv != null) { if (tv != null) { int lvl = cur.getLevel(); if (lvl > 0) tv.setText(((Integer) lvl).toString()); else tv.setText(""); } tv.setOnLongClickListener(listener); registerForContextMenu(tv); } tv = (TextView) findViewById(R.id.Race); if (tv != null) { tv.setText(cur.getRace()); tv.setOnLongClickListener(listener); registerForContextMenu(tv); } tv = (TextView) findViewById(R.id.Ex); if (tv != null) { if (cur.isEx()) tv.setVisibility(View.VISIBLE); else tv.setVisibility(View.INVISIBLE); tv.setOnLongClickListener(listener); registerForContextMenu(tv); } tv = (TextView) findViewById(R.id.Rare); if (tv != null) { if (cur.isRare()) tv.setVisibility(View.VISIBLE); else tv.setVisibility(View.INVISIBLE); tv.setOnLongClickListener(listener); registerForContextMenu(tv); } } } }
From source file:com.github.kanata3249.ffxieq.android.EquipmentSelectorActivity.java
@Override protected void onStart() { super.onStart(); EquipmentListView elv;/*from w ww . j av a 2 s. c om*/ elv = (EquipmentListView) findViewById(R.id.ListView); if (elv != null) { elv.setFilterByID(mFilterID); elv.setOrderByName(mOrderByName); elv.setFilterByType(mFilterByType); elv.setParam(getDAO(), mPart, mRace, mJob, mLevel); elv.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { Intent result = new Intent(); result.putExtra("From", "EquipmentSelector"); result.putExtra("Part", mPart); result.putExtra("Id", arg3); result.putExtra("AugId", -1); setResult(RESULT_OK, result); finish(); } }); elv.setOnItemLongClickListener(new OnItemLongClickListener() { public boolean onItemLongClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { mLongClickingItemId = arg3; mLongClickingItemIsCurrent = false; EquipmentSelectorActivity.this.openContextMenu(arg0); return true; } }); registerForContextMenu(elv); } { Equipment cur = getDAO().instantiateEquipment(mCurrent, mAugID); if (cur == null) { cur = new Equipment(-1, getString(R.string.EquipmentNotSelected), "", "", "", "", 0, 0, false, false, ""); } if (cur != null) { TextView tv; View.OnLongClickListener listener = new View.OnLongClickListener() { public boolean onLongClick(View v) { mLongClickingItemId = mCurrent; mLongClickingItemIsCurrent = true; EquipmentSelectorActivity.this.openContextMenu(v); return true; } }; tv = (TextView) findViewById(R.id.Name); if (tv != null) { tv.setText(cur.getName()); tv.setOnLongClickListener(listener); registerForContextMenu(tv); } tv = (TextView) findViewById(R.id.Job); if (tv != null) { tv.setText(cur.getJob()); tv.setOnLongClickListener(listener); registerForContextMenu(tv); } tv = (TextView) findViewById(R.id.Description); if (tv != null) { tv.setText(cur.getDescription()); tv.setOnLongClickListener(listener); registerForContextMenu(tv); } tv = (TextView) findViewById(R.id.Augment); if (tv != null) { if (cur.getAugment().length() == 0) { tv.setHeight(0); } else { tv.setText(cur.getAugment()); } tv.setOnLongClickListener(listener); registerForContextMenu(tv); } tv = (TextView) findViewById(R.id.Level); if (tv != null) { int lvl = cur.getLevel(); if (lvl > 0) tv.setText(((Integer) lvl).toString()); else tv.setText(""); tv.setOnLongClickListener(listener); registerForContextMenu(tv); } tv = (TextView) findViewById(R.id.Race); if (tv != null) { tv.setText(cur.getRace()); tv.setOnLongClickListener(listener); registerForContextMenu(tv); } tv = (TextView) findViewById(R.id.Ex); if (tv != null) { if (cur.isEx()) tv.setVisibility(View.VISIBLE); else tv.setVisibility(View.INVISIBLE); tv.setOnLongClickListener(listener); registerForContextMenu(tv); } tv = (TextView) findViewById(R.id.Rare); if (tv != null) { if (cur.isRare()) tv.setVisibility(View.VISIBLE); else tv.setVisibility(View.INVISIBLE); tv.setOnLongClickListener(listener); registerForContextMenu(tv); } } } }