List of usage examples for android.view Gravity CENTER_VERTICAL
int CENTER_VERTICAL
To view the source code for android.view Gravity CENTER_VERTICAL.
Click Source Link
From source file:org.silena.main.RegistrationOld.java
private void RenderError(String massage) { LayoutInflater inflater = getLayoutInflater(); View layout = inflater.inflate(R.layout.toast_error, (ViewGroup) findViewById(R.id.toast_layout_root)); TextView text = (TextView) layout.findViewById(R.id.text); text.setText(massage);/*from ww w . j a v a 2 s . c om*/ Toast toast = new Toast(getApplicationContext()); toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0); toast.setDuration(Toast.LENGTH_LONG); toast.setView(layout); toast.show(); return; }
From source file:org.zywx.wbpalmstar.plugin.uexPopoverMenu.EUExPopoverMenu.java
private void showPopoverMenu(double x, double y, int direction, String bgColorStr, String dividerColor, String textColor, int textSize, JSONArray data) { LinearLayout rootView = (LinearLayout) LayoutInflater.from(mContext) .inflate(finder.getLayoutId("plugin_uex_popovermenu"), null); final PopupWindow popupWindow = new PopupWindow(rootView, LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT, true); popupWindow.setContentView(rootView); ////from ww w . j a v a2 s . c o m rootView.setBackgroundColor(Color.parseColor(bgColorStr)); popupWindow.setContentView(rootView); //popupWindow? popupWindow.setBackgroundDrawable(new BitmapDrawable()); popupWindow.setOutsideTouchable(true); int length = data.length(); List<ItemData> itemDataList = new ArrayList<ItemData>(); try { for (int i = 0; i < length; i++) { ItemData item = new ItemData(); String icon = data.getJSONObject(i).optString("icon", ""); if (!hasIcon && !TextUtils.isEmpty(icon)) { hasIcon = true; } if (hasIcon) { item.setIcon(data.getJSONObject(i).getString("icon")); } item.setText(data.getJSONObject(i).getString("text")); itemDataList.add(item); } } catch (JSONException e) { e.printStackTrace(); } for (int i = 0; i < length; i++) { LinearLayout linearLayout = new LinearLayout(mContext); linearLayout.setOrientation(LinearLayout.HORIZONTAL); linearLayout.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); if (hasIcon) { ImageView imageView = new ImageView(mContext); imageView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); String imagePath = itemDataList.get(i).getIcon(); imageView.setImageBitmap(getBitmapFromPath(imagePath)); imageView.setPadding(DensityUtil.dip2px(mContext, 5), 0, 0, 0); linearLayout.addView(imageView); } TextView tvText = new TextView(mContext); LinearLayout.LayoutParams tvLayoutParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); tvLayoutParams.gravity = Gravity.CENTER_VERTICAL; tvText.setLayoutParams(tvLayoutParams); tvText.setPadding(DensityUtil.dip2px(mContext, 5), 0, DensityUtil.dip2px(mContext, 8), 0); tvText.setText(itemDataList.get(i).getText()); tvText.setTextColor(Color.parseColor(textColor)); tvText.setTextSize(textSize); linearLayout.addView(tvText); linearLayout.setTag(i); linearLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { callBackPluginJs(CALLBACK_ITEM_SELECTED, String.valueOf(v.getTag())); if (popupWindow != null && popupWindow.isShowing()) { popupWindow.dismiss(); } } }); rootView.addView(linearLayout); // View dividerLine = new View(mContext); dividerLine.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, DensityUtil.dip2px(mContext, 1))); dividerLine.setBackgroundColor(Color.parseColor(dividerColor)); rootView.addView(dividerLine); } int gravityParam; switch (direction) { case 0: gravityParam = Gravity.LEFT | Gravity.TOP; break; case 1: gravityParam = Gravity.RIGHT | Gravity.TOP; break; case 2: gravityParam = Gravity.LEFT | Gravity.BOTTOM; break; case 3: gravityParam = Gravity.RIGHT | Gravity.BOTTOM; break; default: gravityParam = Gravity.LEFT | Gravity.TOP; break; } popupWindow.showAtLocation(mBrwView.getRootView(), gravityParam, (int) x, (int) y); }
From source file:ticwear.design.widget.CollapsingToolbarLayout.java
public CollapsingToolbarLayout(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); mCollapsingTextHelper = new CollapsingTextHelper(this); mCollapsingTextHelper.setTextSizeInterpolator(AnimationUtils.DECELERATE_INTERPOLATOR); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CollapsingToolbarLayout, defStyleAttr, R.style.Widget_Ticwear_CollapsingToolbar); mCollapsingTextHelper/*w ww.j av a 2 s.c om*/ .setExpandedTextGravity(a.getInt(R.styleable.CollapsingToolbarLayout_tic_expandedTitleGravity, GravityCompat.START | Gravity.BOTTOM)); mCollapsingTextHelper .setCollapsedTextGravity(a.getInt(R.styleable.CollapsingToolbarLayout_tic_collapsedTitleGravity, GravityCompat.START | Gravity.CENTER_VERTICAL)); mExpandedMarginStart = mExpandedMarginTop = mExpandedMarginEnd = mExpandedMarginBottom = a .getDimensionPixelSize(R.styleable.CollapsingToolbarLayout_tic_expandedTitleMargin, 0); if (a.hasValue(R.styleable.CollapsingToolbarLayout_tic_expandedTitleMarginStart)) { mExpandedMarginStart = a .getDimensionPixelSize(R.styleable.CollapsingToolbarLayout_tic_expandedTitleMarginStart, 0); } if (a.hasValue(R.styleable.CollapsingToolbarLayout_tic_expandedTitleMarginEnd)) { mExpandedMarginEnd = a .getDimensionPixelSize(R.styleable.CollapsingToolbarLayout_tic_expandedTitleMarginEnd, 0); } if (a.hasValue(R.styleable.CollapsingToolbarLayout_tic_expandedTitleMarginTop)) { mExpandedMarginTop = a .getDimensionPixelSize(R.styleable.CollapsingToolbarLayout_tic_expandedTitleMarginTop, 0); } if (a.hasValue(R.styleable.CollapsingToolbarLayout_tic_expandedTitleMarginBottom)) { mExpandedMarginBottom = a .getDimensionPixelSize(R.styleable.CollapsingToolbarLayout_tic_expandedTitleMarginBottom, 0); } mCollapsingTitleEnabled = a.getBoolean(R.styleable.CollapsingToolbarLayout_tic_titleEnabled, true); setTitle(a.getText(R.styleable.CollapsingToolbarLayout_android_title)); // First load the default text appearances mCollapsingTextHelper.setExpandedTextAppearance(R.style.TextAppearance_Ticwear_CollapsingToolbar_Expanded); mCollapsingTextHelper.setCollapsedTextAppearance(R.style.TextAppearance_Ticwear_TitleBar_Title); // Now overlay any custom text appearances if (a.hasValue(R.styleable.CollapsingToolbarLayout_tic_expandedTitleTextAppearance)) { mCollapsingTextHelper.setExpandedTextAppearance( a.getResourceId(R.styleable.CollapsingToolbarLayout_tic_expandedTitleTextAppearance, 0)); } if (a.hasValue(R.styleable.CollapsingToolbarLayout_tic_collapsedTitleTextAppearance)) { mCollapsingTextHelper.setCollapsedTextAppearance( a.getResourceId(R.styleable.CollapsingToolbarLayout_tic_collapsedTitleTextAppearance, 0)); } setContentScrim(a.getDrawable(R.styleable.CollapsingToolbarLayout_tic_contentScrim)); setStatusBarScrim(a.getDrawable(R.styleable.CollapsingToolbarLayout_tic_statusBarScrim)); mToolbarId = a.getResourceId(R.styleable.CollapsingToolbarLayout_tic_toolbarId, -1); a.recycle(); setWillNotDraw(false); ViewCompat.setOnApplyWindowInsetsListener(this, new android.support.v4.view.OnApplyWindowInsetsListener() { @Override public WindowInsetsCompat onApplyWindowInsets(View v, WindowInsetsCompat insets) { if (isShown()) { mLastInsets = insets; requestLayout(); return insets.consumeSystemWindowInsets(); } else { return insets; } } }); }
From source file:com.uzmap.pkg.uzmodules.uzBMap.mode.Billboard.java
private TextView subTitle() { TextView title = new TextView(context); title.setSingleLine();/*from w w w. j av a 2 s . co m*/ title.setEllipsize(TruncateAt.END); title.setMaxWidth(UZCoreUtil.dipToPix(maxWidth) - 2 * iconMarginLeft + iconSize); title.setText(getSubTitle()); title.setTextColor(getSubTitleColor()); title.setTextSize(getSubTitleSize()); title.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL); return title; }
From source file:com.nagopy.android.xposed.utilities.ModBrightness.java
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) @XMinSdkVersion(Build.VERSION_CODES.JELLY_BEAN_MR1) @HandleInitPackageResources(targetPackage = XConst.PKG_SYSTEM_UI, summary = "??") public static void brightnessDebugger(final String modulePath, final InitPackageResourcesParam resparam, final ModBrightnessSettingsGen settings) throws Throwable { if (!settings.brightnessDebugger) { return;// www .j av a 2 s. c o m } resparam.res.hookLayout(XConst.PKG_SYSTEM_UI, "layout", "super_status_bar", new XC_LayoutInflated() { @Override public void handleLayoutInflated(LayoutInflatedParam liparam) throws Throwable { LinearLayout parent = (LinearLayout) liparam.view .findViewById(liparam.res.getIdentifier("system_icon_area", "id", XConst.PKG_SYSTEM_UI)); // ? TextView luxTextView = new TextView(parent.getContext()); luxTextView.setTextSize(8); luxTextView.setSingleLine(false); luxTextView.setTextColor(Color.WHITE); luxTextView.setText(""); parent.setGravity(Gravity.CENTER_VERTICAL); parent.addView(luxTextView, 0); AutoBrightnessController autoBrightnessChangedReceiver = new AutoBrightnessController(luxTextView); IntentFilter intentFilter = new IntentFilter( AutoBrightnessController.ACTION_AUTO_BRIGHTNESS_CHANGED); intentFilter.addAction(Intent.ACTION_SCREEN_OFF); parent.getContext().registerReceiver(autoBrightnessChangedReceiver, intentFilter); } }); }
From source file:angeloid.dreamnarae.SwipeyTabs.java
/** * Update the ellipsize of the text views *//*from ww w. jav a 2s.c o m*/ private void updateEllipsize() { if (mAdapter == null) { return; } final int count = mAdapter.getCount(); for (int i = 0; i < count; i++) { TextView tab = (TextView) getChildAt(i); if (i < mCurrentPos) { tab.setEllipsize(null); tab.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL); } else if (i == mCurrentPos) { tab.setEllipsize(TruncateAt.END); tab.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL); } else if (i > mCurrentPos) { tab.setEllipsize(null); tab.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL); } } }
From source file:com.mishiranu.dashchan.ui.navigator.DrawerForm.java
public DrawerForm(Context context, Context unstyledContext, Callback callback, WatcherService.Client watcherServiceClient) { this.context = context; this.unstyledContext = unstyledContext; this.callback = callback; this.watcherServiceClient = watcherServiceClient; float density = ResourceUtils.obtainDensity(context); LinearLayout linearLayout = new LinearLayout(context); linearLayout.setOrientation(LinearLayout.VERTICAL); linearLayout.setLayoutParams(new SortableListView.LayoutParams(SortableListView.LayoutParams.MATCH_PARENT, SortableListView.LayoutParams.WRAP_CONTENT)); LinearLayout editTextContainer = new LinearLayout(context); editTextContainer.setGravity(Gravity.CENTER_VERTICAL); linearLayout.addView(editTextContainer); searchEdit = new SafePasteEditText(context); searchEdit.setOnKeyListener((v, keyCode, event) -> { if (event.getAction() == KeyEvent.ACTION_UP && keyCode == KeyEvent.KEYCODE_BACK) { v.clearFocus();// ww w .j a va 2 s . co m } return false; }); searchEdit.setHint(context.getString(R.string.text_code_number_address)); searchEdit.setOnEditorActionListener(this); searchEdit.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI); searchEdit.setImeOptions(EditorInfo.IME_ACTION_GO | EditorInfo.IME_FLAG_NO_EXTRACT_UI); ImageView searchIcon = new ImageView(context, null, android.R.attr.buttonBarButtonStyle); searchIcon.setImageResource(ResourceUtils.getResourceId(context, R.attr.buttonForward, 0)); searchIcon.setScaleType(ImageView.ScaleType.CENTER); searchIcon.setOnClickListener(this); editTextContainer.addView(searchEdit, new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.WRAP_CONTENT, 1)); editTextContainer.addView(searchIcon, (int) (40f * density), (int) (40f * density)); if (C.API_LOLLIPOP) { editTextContainer.setPadding((int) (12f * density), (int) (8f * density), (int) (8f * density), 0); } else { editTextContainer.setPadding(0, (int) (2f * density), (int) (4f * density), (int) (2f * density)); } LinearLayout selectorContainer = new LinearLayout(context); selectorContainer.setBackgroundResource( ResourceUtils.getResourceId(context, android.R.attr.selectableItemBackground, 0)); selectorContainer.setOrientation(LinearLayout.HORIZONTAL); selectorContainer.setGravity(Gravity.CENTER_VERTICAL); selectorContainer.setOnClickListener(v -> { hideKeyboard(); setChanSelectMode(!chanSelectMode); }); linearLayout.addView(selectorContainer); selectorContainer.setMinimumHeight((int) (40f * density)); if (C.API_LOLLIPOP) { selectorContainer.setPadding((int) (16f * density), 0, (int) (16f * density), 0); ((LinearLayout.LayoutParams) selectorContainer.getLayoutParams()).topMargin = (int) (4f * density); } else { selectorContainer.setPadding((int) (8f * density), 0, (int) (12f * density), 0); } chanNameView = new TextView(context, null, android.R.attr.textAppearanceListItem); chanNameView.setTextSize(TypedValue.COMPLEX_UNIT_SP, C.API_LOLLIPOP ? 14f : 16f); if (C.API_LOLLIPOP) { chanNameView.setTypeface(GraphicsUtils.TYPEFACE_MEDIUM); } else { chanNameView.setFilters(new InputFilter[] { new InputFilter.AllCaps() }); } selectorContainer.addView(chanNameView, new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.WRAP_CONTENT, 1)); chanSelectorIcon = new ImageView(context); chanSelectorIcon.setImageResource(ResourceUtils.getResourceId(context, R.attr.buttonDropDownDrawer, 0)); selectorContainer.addView(chanSelectorIcon, (int) (24f * density), (int) (24f * density)); ((LinearLayout.LayoutParams) chanSelectorIcon.getLayoutParams()).gravity = Gravity.CENTER_VERTICAL | Gravity.END; headerView = linearLayout; inputMethodManager = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE); chans.add(new ListItem(ListItem.ITEM_DIVIDER, 0, 0, null)); int color = ResourceUtils.getColor(context, R.attr.drawerIconColor); ChanManager manager = ChanManager.getInstance(); Collection<String> availableChans = manager.getAvailableChanNames(); for (String chanName : availableChans) { ChanConfiguration configuration = ChanConfiguration.get(chanName); if (configuration.getOption(ChanConfiguration.OPTION_READ_POSTS_COUNT)) { watcherSupportSet.add(chanName); } Drawable drawable = manager.getIcon(chanName, color); chanIcons.put(chanName, drawable); chans.add( new ListItem(ListItem.ITEM_CHAN, chanName, null, null, configuration.getTitle(), 0, drawable)); } if (availableChans.size() == 1) { selectorContainer.setVisibility(View.GONE); } }
From source file:android.support.designox.widget.CollapsingToolbarLayout.java
public CollapsingToolbarLayout(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); ThemeUtils.checkAppCompatTheme(context); mCollapsingTextHelper = new CollapsingTextHelper(this); mCollapsingTextHelper.setTextSizeInterpolator(AnimationUtils.DECELERATE_INTERPOLATOR); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CollapsingToolbarLayout, defStyleAttr, R.style.Widget_Design_CollapsingToolbar); mCollapsingTextHelper.setExpandedTextGravity(a.getInt( R.styleable.CollapsingToolbarLayout_expandedTitleGravity, GravityCompat.START | Gravity.BOTTOM)); mCollapsingTextHelper/*from w w w . j a va 2s .c o m*/ .setCollapsedTextGravity(a.getInt(R.styleable.CollapsingToolbarLayout_collapsedTitleGravity, GravityCompat.START | Gravity.CENTER_VERTICAL)); mExpandedMarginStart = mExpandedMarginTop = mExpandedMarginEnd = mExpandedMarginBottom = a .getDimensionPixelSize(R.styleable.CollapsingToolbarLayout_expandedTitleMargin, 0); if (a.hasValue(R.styleable.CollapsingToolbarLayout_expandedTitleMarginStart)) { mExpandedMarginStart = a .getDimensionPixelSize(R.styleable.CollapsingToolbarLayout_expandedTitleMarginStart, 0); } if (a.hasValue(R.styleable.CollapsingToolbarLayout_expandedTitleMarginEnd)) { mExpandedMarginEnd = a.getDimensionPixelSize(R.styleable.CollapsingToolbarLayout_expandedTitleMarginEnd, 0); } if (a.hasValue(R.styleable.CollapsingToolbarLayout_expandedTitleMarginTop)) { mExpandedMarginTop = a.getDimensionPixelSize(R.styleable.CollapsingToolbarLayout_expandedTitleMarginTop, 0); } if (a.hasValue(R.styleable.CollapsingToolbarLayout_expandedTitleMarginBottom)) { mExpandedMarginBottom = a .getDimensionPixelSize(R.styleable.CollapsingToolbarLayout_expandedTitleMarginBottom, 0); } mCollapsingTitleEnabled = a.getBoolean(R.styleable.CollapsingToolbarLayout_titleEnabled, true); setTitle(a.getText(R.styleable.CollapsingToolbarLayout_title)); // First load the default text appearances mCollapsingTextHelper.setExpandedTextAppearance(R.style.TextAppearance_Design_CollapsingToolbar_Expanded); mCollapsingTextHelper.setCollapsedTextAppearance(R.style.TextAppearance_AppCompat_Widget_ActionBar_Title); // Now overlay any custom text appearances if (a.hasValue(R.styleable.CollapsingToolbarLayout_expandedTitleTextAppearance)) { mCollapsingTextHelper.setExpandedTextAppearance( a.getResourceId(R.styleable.CollapsingToolbarLayout_expandedTitleTextAppearance, 0)); } if (a.hasValue(R.styleable.CollapsingToolbarLayout_collapsedTitleTextAppearance)) { mCollapsingTextHelper.setCollapsedTextAppearance( a.getResourceId(R.styleable.CollapsingToolbarLayout_collapsedTitleTextAppearance, 0)); } setContentScrim(a.getDrawable(R.styleable.CollapsingToolbarLayout_contentScrim)); setStatusBarScrim(a.getDrawable(R.styleable.CollapsingToolbarLayout_statusBarScrim)); mToolbarId = a.getResourceId(R.styleable.CollapsingToolbarLayout_toolbarId, -1); a.recycle(); setWillNotDraw(false); ViewCompat.setOnApplyWindowInsetsListener(this, new android.support.v4ox.view.OnApplyWindowInsetsListener() { @Override public WindowInsetsCompat onApplyWindowInsets(View v, WindowInsetsCompat insets) { return setWindowInsets(insets); } }); }
From source file:com.cssweb.android.quote.QuoteDetail.java
/** * //from ww w . j a v a2s . co m * @param jArr * @param table * @param zrsp * @throws JSONException */ private void appendRow(JSONArray jArr, TableLayout table, double zrsp) throws JSONException { table.setStretchAllColumns(true); table.removeAllViews(); if ("cf".equals(exchange.toLowerCase()) || "dc".equals(exchange.toLowerCase()) || "sf".equals(exchange.toLowerCase()) || "cz".equals(exchange.toLowerCase())) { int len = jArr.length(); int color = Utils.getTextColor(mContext, 0); for (int i = 0; i < len; i++) { LinearLayout linearLayout = (LinearLayout) findViewById(R.id.title23); linearLayout.setVisibility(View.VISIBLE); JSONArray jA = (JSONArray) jArr.get(i); TableRow row = (TableRow) LayoutInflater.from(this).inflate(R.layout.zr_quote_price_item, null); TextView t1 = (TextView) row.findViewById(R.id.zr_table_col1); TextView t2 = (TextView) row.findViewById(R.id.zr_table_col2); TextView t3 = (TextView) row.findViewById(R.id.zr_table_col3); TextView t4 = (TextView) row.findViewById(R.id.zr_table_col4); TextView t5 = (TextView) row.findViewById(R.id.zr_table_col5); t1.setText(jA.getString(4)); t2.setText(Utils.dataFormation(jA.getDouble(0), Utils.getStockDigit(type))); t2.setTextColor(Utils.getTextColor(mContext, jA.getDouble(0), zrsp)); t2.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL); double cjsl = Arith.round(jA.getDouble(1), 0); t3.setText(Utils.dataFormation(cjsl, 0)); t3.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL); t4.setText(jA.getString(7)); t5.setText(jA.getString(8)); table.addView(row); if ("B".equals(jA.getString(6))) { color = Utils.getTextColor(mContext, 3); t3.setTextColor(color); t4.setTextColor(color); t5.setTextColor(color); } else if ("S".equals(jA.getString(6))) { color = Utils.getTextColor(mContext, 4); t3.setTextColor(color); t4.setTextColor(color); t5.setTextColor(color); } else { t3.setTextColor(color); t4.setTextColor(color); t5.setTextColor(color); } } } else { if (stocktype.charAt(0) == '0') {// //for (int i = jArr.length()-1; i >= 0; i--) { for (int i = 0; i <= jArr.length() - 1; i++) { JSONArray jA = (JSONArray) jArr.get(i); TableRow row = (TableRow) LayoutInflater.from(this).inflate(R.layout.zr_quote_price_item, null); TextView t1 = (TextView) row.findViewById(R.id.zr_table_col1); TextView t2 = (TextView) row.findViewById(R.id.zr_table_col2); TextView t3 = (TextView) row.findViewById(R.id.zr_table_col3); TextView t4 = (TextView) row.findViewById(R.id.zr_table_col4); t1.setText(jA.getString(4)); t2.setText(Utils.dataFormation(jA.getDouble(0), Utils.getStockDigit(type))); t2.setTextColor(Utils.getTextColor(mContext, jA.getDouble(0), zrsp)); t2.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL); double cjsl = Arith.round(jA.getDouble(1), 0); t3.setText(Utils.dataFormation(cjsl, 0)); if (cjsl > 500) t3.setTextColor(Utils.getTextColor(mContext, 6)); else t3.setTextColor(Utils.getTextColor(mContext, 1)); t3.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL); t4.setText(jA.getString(6)); if ("B".equals(jA.getString(6))) t4.setTextColor(Utils.getTextColor(mContext, 3)); else t4.setTextColor(Utils.getTextColor(mContext, 4)); table.addView(row); } //? int num = jArr.length(); if (num < 16) { while (num < 16) { TableRow row = (TableRow) LayoutInflater.from(this).inflate(R.layout.zr_quote_price_item, null); table.addView(row); num++; } } } else if (stocktype.charAt(0) == '1' || stocktype.charAt(0) == '2') {// //for (int i = jArr.length()-1; i >= 0; i--) { for (int i = 0; i <= jArr.length() - 1; i++) { JSONArray jA = (JSONArray) jArr.get(i); TableRow row = (TableRow) LayoutInflater.from(this).inflate(R.layout.zr_quote_price_item, null); TextView t1 = (TextView) row.findViewById(R.id.zr_table_col1); TextView t2 = (TextView) row.findViewById(R.id.zr_table_col2); TextView t3 = (TextView) row.findViewById(R.id.zr_table_col4); t1.setText(jA.getString(4)); t2.setText(Utils.dataFormation(jA.getDouble(0), Utils.getStockDigit(type))); t2.setTextColor(Utils.getTextColor(mContext, jA.getDouble(0), zrsp)); t3.setText(Utils.getAmountFormat(jA.getDouble(5), true)); t3.setTextColor(Utils.getTextColor(mContext, 1)); table.addView(row); } //? int num = jArr.length(); if (num < 16) { while (num < 16) { TableRow row = (TableRow) LayoutInflater.from(this).inflate(R.layout.zr_quote_price_item, null); table.addView(row); num++; } } } } }
From source file:com.chess.genesis.view.SwipeTabs.java
/** * Update the ellipsize of the text views *//*from w w w . j av a2 s .co m*/ private void updateEllipsize() { if (mAdapter == null) return; final int count = mAdapter.getCount(); for (int i = 0; i < count; i++) { final TextView tab = (TextView) getChildAt(i); if (i < mCurrentPos) { tab.setEllipsize(null); tab.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL); } else if (i == mCurrentPos) { tab.setEllipsize(TruncateAt.END); tab.setGravity(Gravity.CENTER | Gravity.CENTER_VERTICAL); } else if (i > mCurrentPos) { tab.setEllipsize(null); tab.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL); } } }