List of usage examples for android.view Gravity CENTER_HORIZONTAL
int CENTER_HORIZONTAL
To view the source code for android.view Gravity CENTER_HORIZONTAL.
Click Source Link
From source file:com.twolinessoftware.smarterlist.activity.BaseActivity.java
public Crouton getInfoCrouton(String message) { Style style = new Style.Builder().setHeightDimensionResId(R.dimen.crouton_height) .setGravity(Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM) .setBackgroundColorValue(getResources().getColor(R.color.pal_blue)) .setTextAppearance(R.style.SmarterList_TextStyle_Body_Bold).build(); return Crouton.makeText(this, message, style, R.id.container); }
From source file:com.tmall.ultraviewpager.UltraViewPagerIndicator.java
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); if (viewPager == null || viewPager.getAdapter() == null) return;//from w w w . java2s . com final int count = ((UltraViewPagerAdapter) viewPager.getAdapter()).getRealCount(); if (count == 0) return; int longSize; int shortSize; int longPaddingBefore; int longPaddingAfter; int shortPaddingBefore; int shortPaddingAfter; if (orientation == UltraViewPager.Orientation.HORIZONTAL) { longSize = viewPager.getWidth(); shortSize = viewPager.getHeight(); longPaddingBefore = getPaddingLeft() + marginLeft; longPaddingAfter = getPaddingRight() + marginRight; shortPaddingBefore = getPaddingTop() + marginTop; shortPaddingAfter = (int) paintStroke.getStrokeWidth() + getPaddingBottom() + marginBottom; } else { longSize = viewPager.getHeight(); shortSize = viewPager.getWidth(); longPaddingBefore = getPaddingTop() + marginTop; longPaddingAfter = (int) paintStroke.getStrokeWidth() + getPaddingBottom() + marginBottom; shortPaddingBefore = getPaddingLeft() + marginLeft; shortPaddingAfter = getPaddingRight() + marginRight; } final float itemWidth = getItemWidth(); final int widthRatio = isDrawResIndicator() ? 1 : 2; //bitmap resource X1 : circle X2 if (indicatorPadding == 0) { indicatorPadding = (int) itemWidth; } float shortOffset = shortPaddingBefore; float longOffset = longPaddingBefore; final float indicatorLength = (count - 1) * (itemWidth * widthRatio + indicatorPadding); final int horizontalGravityMask = gravity & Gravity.HORIZONTAL_GRAVITY_MASK; final int verticalGravityMask = gravity & Gravity.VERTICAL_GRAVITY_MASK; switch (horizontalGravityMask) { case Gravity.CENTER_HORIZONTAL: longOffset = (longSize - longPaddingBefore - longPaddingAfter - indicatorLength) / 2.0f; break; case Gravity.RIGHT: if (orientation == UltraViewPager.Orientation.HORIZONTAL) { longOffset = longSize - longPaddingAfter - indicatorLength - itemWidth; } if (orientation == UltraViewPager.Orientation.VERTICAL) { shortOffset = shortSize - shortPaddingAfter - itemWidth; } break; case Gravity.LEFT: longOffset += itemWidth; default: break; } switch (verticalGravityMask) { case Gravity.CENTER_VERTICAL: shortOffset = (shortSize - shortPaddingAfter - shortPaddingBefore - itemWidth) / 2; break; case Gravity.BOTTOM: if (orientation == UltraViewPager.Orientation.HORIZONTAL) { shortOffset = shortSize - shortPaddingAfter - getItemHeight(); } if (orientation == UltraViewPager.Orientation.VERTICAL) { longOffset = longSize - longPaddingAfter - indicatorLength; } break; case Gravity.TOP: shortOffset += itemWidth; default: break; } if (horizontalGravityMask == Gravity.CENTER_HORIZONTAL && verticalGravityMask == Gravity.CENTER_VERTICAL) { shortOffset = (shortSize - shortPaddingAfter - shortPaddingBefore - itemWidth) / 2; } float dX; float dY; float pageFillRadius = radius; if (paintStroke.getStrokeWidth() > 0) { pageFillRadius -= paintStroke.getStrokeWidth() / 2.0f; //TODO may not/2 } //Draw stroked circles for (int iLoop = 0; iLoop < count; iLoop++) { float drawLong = longOffset + (iLoop * (itemWidth * widthRatio + indicatorPadding)); if (orientation == UltraViewPager.Orientation.HORIZONTAL) { dX = drawLong; dY = shortOffset; } else { dX = shortOffset; dY = drawLong; } if (isDrawResIndicator()) { if (iLoop == viewPager.getCurrentItem()) continue; canvas.drawBitmap(normalBitmap, dX, dY, paintFill); } else { // Only paint fill if not completely transparent if (paintFill.getAlpha() > 0) { paintFill.setColor(normalColor); canvas.drawCircle(dX, dY, pageFillRadius, paintFill); } // Only paint stroke if a stroke width was non-zero if (pageFillRadius != radius) { canvas.drawCircle(dX, dY, radius, paintStroke); } } } //Draw the filled circle according to the current scroll float cx = (viewPager.getCurrentItem()) * (itemWidth * widthRatio + indicatorPadding); if (animateIndicator) cx += pageOffset * itemWidth; if (orientation == UltraViewPager.Orientation.HORIZONTAL) { dX = longOffset + cx; dY = shortOffset; } else { dX = shortOffset; dY = longOffset + cx; } if (isDrawResIndicator()) { canvas.drawBitmap(focusBitmap, dX, dY, paintStroke); } else { paintFill.setColor(focusColor); canvas.drawCircle(dX, dY, radius, paintFill); } }
From source file:com.adarshahd.indianrailinfo.donate.PNRStat.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.layout_pnr_status); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setTitle("PNR Status"); mUtil = Util.getUtil(this); mBtnPNR = ((Button) findViewById(R.id.id_btn_get_pnr_sts)); mBtnPNR.setOnClickListener(this); pnrDB = PNRDatabase.getPNRDatabase(this); mPNRList = new ArrayList<String>(); mPNRList = pnrDB.getPNRs();/*from w ww . j av a2 s . c om*/ mACTPNR = (AutoCompleteTextView) findViewById(R.id.id_act_pnr_sts); mACTPNR.setAdapter(new ArrayAdapter<String>(this, R.layout.layout_dropdown_list, mPNRList)); mPref = PreferenceManager.getDefaultSharedPreferences(this); isWaitingList = false; if (savedInstanceState != null) { if (!mPNRNumber.equals("")) { if (!mUtil.isConnected()) { mFrameLayout = null; mFrameLayout = (FrameLayout) findViewById(R.id.id_fl_pnr); readAndShowOfflinePNRStatus(); return; } mFrameLayout = null; mFrameLayout = (FrameLayout) findViewById(R.id.id_fl_pnr); mPassengerDetails = savedInstanceState.getParcelable("PSN"); mTrainDetails = savedInstanceState.getParcelable("TRAIN"); mPageResult = savedInstanceState.getString("PAGE"); if (mPageResult == null) { return; } mTextViewPNRSts = null; mTextViewPNRSts = new TextView(mActivity); mTextViewPNRSts.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); mTextViewPNRSts.setGravity(Gravity.CENTER_HORIZONTAL); mTextViewPNRSts.setTextColor(Color.RED); createTableLayoutTrnDtls(); createTableLayoutPsnDtls(); try { combineTrainAndPsnDetails(); } catch (Exception e) { Log.e("PNRStat Error:", "Error creating table layout. Please try again later!"); } return; } } mActivity = this; mFrameLayout = (FrameLayout) findViewById(R.id.id_fl_pnr); mBtnPNR = ((Button) findViewById(R.id.id_btn_get_pnr_sts)); mBtnPNR.setOnClickListener(this); mTextViewPNRSts = new TextView(mActivity); mTextViewPNRSts.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); mTextViewPNRSts.setGravity(Gravity.CENTER_HORIZONTAL); mTextViewPNRSts.setTextColor(Color.RED); }
From source file:com.qs.qswlw.view.Mypager.UltraViewPagerIndicator.java
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); if (viewPager == null || viewPager.getAdapter() == null) return;//from ww w . j a va2s . com final int count = ((UltraViewPagerAdapter) viewPager.getAdapter()).getRealCount(); if (count == 0) return; int longSize; int shortSize; int longPaddingBefore; int longPaddingAfter; int shortPaddingBefore; int shortPaddingAfter; if (orientation == UltraViewPager.Orientation.HORIZONTAL) { longSize = viewPager.getWidth(); shortSize = viewPager.getHeight(); longPaddingBefore = (int) (getItemWidth() + getPaddingLeft() + marginLeft); longPaddingAfter = getPaddingRight() + marginRight; shortPaddingBefore = (int) (getItemWidth() + getPaddingTop() + marginTop); shortPaddingAfter = (int) paintStroke.getStrokeWidth() + getPaddingBottom() + marginBottom; } else { longSize = viewPager.getHeight(); shortSize = viewPager.getWidth(); longPaddingBefore = (int) (getItemWidth() + getPaddingTop() + marginTop); longPaddingAfter = (int) paintStroke.getStrokeWidth() + getPaddingBottom() + marginBottom; shortPaddingBefore = (int) (getItemWidth() + getPaddingLeft() + marginLeft); shortPaddingAfter = getPaddingRight() + marginRight; } final float itemWidth = getItemWidth(); final int widthRatio = isDrawResIndicator() ? 1 : 2; //bitmap resource X1 : circle X2 if (indicatorPadding == 0) { indicatorPadding = (int) itemWidth; } float shortOffset = shortPaddingBefore; float longOffset = longPaddingBefore; final float indicatorLength = count * itemWidth * widthRatio + (count - 1) * indicatorPadding; final int horizontalGravityMask = gravity & Gravity.HORIZONTAL_GRAVITY_MASK; final int verticalGravityMask = gravity & Gravity.VERTICAL_GRAVITY_MASK; switch (horizontalGravityMask) { case Gravity.CENTER_HORIZONTAL: longOffset = (longSize - longPaddingBefore - longPaddingAfter - indicatorLength) / 2.0f; break; case Gravity.RIGHT: if (orientation == UltraViewPager.Orientation.HORIZONTAL) { longOffset = longSize - longPaddingAfter - indicatorLength; } if (orientation == UltraViewPager.Orientation.VERTICAL) { shortOffset = shortSize - shortPaddingAfter - itemWidth; } break; case Gravity.LEFT: default: break; } switch (verticalGravityMask) { case Gravity.CENTER_VERTICAL: shortOffset = (shortSize - shortPaddingAfter - shortPaddingBefore - itemWidth) / 2; break; case Gravity.BOTTOM: if (orientation == UltraViewPager.Orientation.HORIZONTAL) { shortOffset = shortSize - shortPaddingAfter - getItemHeight(); } if (orientation == UltraViewPager.Orientation.VERTICAL) { longOffset = longSize - longPaddingAfter - indicatorLength; } break; case Gravity.TOP: default: break; } if (horizontalGravityMask == Gravity.CENTER_HORIZONTAL && verticalGravityMask == Gravity.CENTER_VERTICAL) { shortOffset = (shortSize - shortPaddingAfter - shortPaddingBefore - itemWidth) / 2; } float dX; float dY; float pageFillRadius = radius; if (paintStroke.getStrokeWidth() > 0) { pageFillRadius -= paintStroke.getStrokeWidth() / 2.0f; //TODO may not/2 } //Draw stroked circles for (int iLoop = 0; iLoop < count; iLoop++) { float drawLong = longOffset + (iLoop * (itemWidth * widthRatio + indicatorPadding)); if (orientation == UltraViewPager.Orientation.HORIZONTAL) { dX = drawLong; dY = shortOffset; } else { dX = shortOffset; dY = drawLong; } if (isDrawResIndicator()) { if (iLoop == viewPager.getCurrentItem()) continue; canvas.drawBitmap(normalBitmap, dX, dY, paintFill); } else { // Only paint fill if not completely transparent if (paintFill.getAlpha() > 0) { paintFill.setColor(normalColor); canvas.drawCircle(dX, dY, pageFillRadius, paintFill); } // Only paint stroke if a stroke width was non-zero if (pageFillRadius != radius) { canvas.drawCircle(dX, dY, radius, paintStroke); } } } //Draw the filled circle according to the current scroll float cx = (viewPager.getCurrentItem()) * (itemWidth * widthRatio + indicatorPadding); if (animateIndicator) cx += pageOffset * itemWidth; if (orientation == UltraViewPager.Orientation.HORIZONTAL) { dX = longOffset + cx; dY = shortOffset; } else { dX = shortOffset; dY = longOffset + cx; } if (isDrawResIndicator()) { canvas.drawBitmap(focusBitmap, dX, dY, paintStroke); } else { paintFill.setColor(focusColor); canvas.drawCircle(dX, dY, radius, paintFill); } }
From source file:com.manuelpeinado.imagelayout.ImageLayout.java
public void setGravity(int newValue) { if (fitter != null && gravity == newValue) { return;/*from w w w . j ava 2 s. c o m*/ } if ((newValue & Gravity.HORIZONTAL_GRAVITY_MASK) == 0) { newValue |= Gravity.CENTER_HORIZONTAL; } if ((newValue & Gravity.VERTICAL_GRAVITY_MASK) == 0) { newValue |= Gravity.CENTER_VERTICAL; } gravity = newValue; rebuildFitter(); }
From source file:com.b44t.ui.Components.PasscodeView.java
public PasscodeView(final Context context) { super(context); setWillNotDraw(false);/* www . j a v a 2 s . c om*/ setVisibility(GONE); backgroundFrameLayout = new FrameLayout(context); addView(backgroundFrameLayout); LayoutParams layoutParams = (LayoutParams) backgroundFrameLayout.getLayoutParams(); layoutParams.width = LayoutHelper.MATCH_PARENT; layoutParams.height = LayoutHelper.MATCH_PARENT; backgroundFrameLayout.setLayoutParams(layoutParams); passwordFrameLayout = new FrameLayout(context); addView(passwordFrameLayout); layoutParams = (LayoutParams) passwordFrameLayout.getLayoutParams(); layoutParams.width = LayoutHelper.MATCH_PARENT; layoutParams.height = LayoutHelper.MATCH_PARENT; layoutParams.gravity = Gravity.TOP | Gravity.LEFT; passwordFrameLayout.setLayoutParams(layoutParams); ImageView imageView = new ImageView(context); imageView.setScaleType(ImageView.ScaleType.FIT_XY); imageView.setImageResource(R.drawable.ic_launcher /* EDIT BY MR -- was: passcode_logo */); passwordFrameLayout.addView(imageView); layoutParams = (LayoutParams) imageView.getLayoutParams(); if (AndroidUtilities.density < 1) { layoutParams.width = AndroidUtilities.dp(30); layoutParams.height = AndroidUtilities.dp(30); } else { layoutParams.width = AndroidUtilities.dp(40); layoutParams.height = AndroidUtilities.dp(40); } layoutParams.gravity = Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM; layoutParams.bottomMargin = AndroidUtilities.dp(100); imageView.setLayoutParams(layoutParams); passcodeTextView = new TextView(context); passcodeTextView.setTextColor(0xffffffff); passcodeTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); passcodeTextView.setGravity(Gravity.CENTER_HORIZONTAL); passwordFrameLayout.addView(passcodeTextView); layoutParams = (LayoutParams) passcodeTextView.getLayoutParams(); layoutParams.width = LayoutHelper.WRAP_CONTENT; layoutParams.height = LayoutHelper.WRAP_CONTENT; layoutParams.bottomMargin = AndroidUtilities.dp(62); layoutParams.gravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL; passcodeTextView.setLayoutParams(layoutParams); passwordEditText = new EditText(context); passwordEditText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 36); passwordEditText.setTextColor(0xffffffff); passwordEditText.setMaxLines(1); passwordEditText.setLines(1); passwordEditText.setGravity(Gravity.CENTER_HORIZONTAL); passwordEditText.setSingleLine(true); passwordEditText.setImeOptions(EditorInfo.IME_ACTION_DONE); passwordEditText.setTypeface(Typeface.DEFAULT); passwordEditText.setBackgroundDrawable(null); AndroidUtilities.clearCursorDrawable(passwordEditText); passwordFrameLayout.addView(passwordEditText); layoutParams = (FrameLayout.LayoutParams) passwordEditText.getLayoutParams(); layoutParams.height = LayoutHelper.WRAP_CONTENT; layoutParams.width = LayoutHelper.MATCH_PARENT; layoutParams.leftMargin = AndroidUtilities.dp(70); layoutParams.rightMargin = AndroidUtilities.dp(70); layoutParams.bottomMargin = AndroidUtilities.dp(6); layoutParams.gravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL; passwordEditText.setLayoutParams(layoutParams); passwordEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) { if (i == EditorInfo.IME_ACTION_DONE) { processDone(false); return true; } return false; } }); passwordEditText.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void afterTextChanged(Editable s) { if (passwordEditText.length() == 4 && UserConfig.passcodeType == 0) { processDone(false); } } }); passwordEditText.setCustomSelectionActionModeCallback(new ActionMode.Callback() { public boolean onPrepareActionMode(ActionMode mode, Menu menu) { return false; } public void onDestroyActionMode(ActionMode mode) { } public boolean onCreateActionMode(ActionMode mode, Menu menu) { return false; } public boolean onActionItemClicked(ActionMode mode, MenuItem item) { return false; } }); checkImage = new ImageView(context); checkImage.setImageResource(R.drawable.passcode_check); checkImage.setScaleType(ImageView.ScaleType.CENTER); checkImage.setBackgroundResource(R.drawable.bar_selector_lock); passwordFrameLayout.addView(checkImage); layoutParams = (LayoutParams) checkImage.getLayoutParams(); layoutParams.width = AndroidUtilities.dp(60); layoutParams.height = AndroidUtilities.dp(60); layoutParams.bottomMargin = AndroidUtilities.dp(4); layoutParams.rightMargin = AndroidUtilities.dp(10); layoutParams.gravity = Gravity.BOTTOM | Gravity.RIGHT; checkImage.setLayoutParams(layoutParams); checkImage.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { processDone(false); } }); FrameLayout lineFrameLayout = new FrameLayout(context); lineFrameLayout.setBackgroundColor(0x26ffffff); passwordFrameLayout.addView(lineFrameLayout); layoutParams = (LayoutParams) lineFrameLayout.getLayoutParams(); layoutParams.width = LayoutHelper.MATCH_PARENT; layoutParams.height = AndroidUtilities.dp(1); layoutParams.gravity = Gravity.BOTTOM | Gravity.LEFT; layoutParams.leftMargin = AndroidUtilities.dp(20); layoutParams.rightMargin = AndroidUtilities.dp(20); lineFrameLayout.setLayoutParams(layoutParams); numbersFrameLayout = new FrameLayout(context); addView(numbersFrameLayout); layoutParams = (LayoutParams) numbersFrameLayout.getLayoutParams(); layoutParams.width = LayoutHelper.MATCH_PARENT; layoutParams.height = LayoutHelper.MATCH_PARENT; layoutParams.gravity = Gravity.TOP | Gravity.LEFT; numbersFrameLayout.setLayoutParams(layoutParams); lettersTextViews = new ArrayList<>(10); numberTextViews = new ArrayList<>(10); numberFrameLayouts = new ArrayList<>(10); for (int a = 0; a < 10; a++) { TextView textView = new TextView(context); textView.setTextColor(0xffffffff); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 36); textView.setGravity(Gravity.CENTER); textView.setText(String.format(Locale.US, "%d", a)); numbersFrameLayout.addView(textView); layoutParams = (LayoutParams) textView.getLayoutParams(); layoutParams.width = AndroidUtilities.dp(50); layoutParams.height = AndroidUtilities.dp(50); layoutParams.gravity = Gravity.TOP | Gravity.LEFT; textView.setLayoutParams(layoutParams); numberTextViews.add(textView); textView = new TextView(context); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12); textView.setTextColor(0x7fffffff); textView.setGravity(Gravity.CENTER); numbersFrameLayout.addView(textView); layoutParams = (LayoutParams) textView.getLayoutParams(); layoutParams.width = AndroidUtilities.dp(50); layoutParams.height = AndroidUtilities.dp(20); layoutParams.gravity = Gravity.TOP | Gravity.LEFT; textView.setLayoutParams(layoutParams); switch (a) { case 0: textView.setText("+"); break; case 2: textView.setText("ABC"); break; case 3: textView.setText("DEF"); break; case 4: textView.setText("GHI"); break; case 5: textView.setText("JKL"); break; case 6: textView.setText("MNO"); break; case 7: textView.setText("PQRS"); break; case 8: textView.setText("TUV"); break; case 9: textView.setText("WXYZ"); break; default: break; } lettersTextViews.add(textView); } eraseView = new ImageView(context); eraseView.setScaleType(ImageView.ScaleType.CENTER); eraseView.setImageResource(R.drawable.passcode_delete); numbersFrameLayout.addView(eraseView); layoutParams = (LayoutParams) eraseView.getLayoutParams(); layoutParams.width = AndroidUtilities.dp(50); layoutParams.height = AndroidUtilities.dp(50); layoutParams.gravity = Gravity.TOP | Gravity.LEFT; eraseView.setLayoutParams(layoutParams); for (int a = 0; a < 11; a++) { FrameLayout frameLayout = new FrameLayout(context); frameLayout.setBackgroundResource(R.drawable.bar_selector_lock); frameLayout.setTag(a); if (a == 10) { frameLayout.setOnLongClickListener(new OnLongClickListener() { @Override public boolean onLongClick(View v) { passwordEditText.setText(""); return true; } }); } frameLayout.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { int tag = (Integer) v.getTag(); switch (tag) { case 0: appendCharacter("0"); break; case 1: appendCharacter("1"); break; case 2: appendCharacter("2"); break; case 3: appendCharacter("3"); break; case 4: appendCharacter("4"); break; case 5: appendCharacter("5"); break; case 6: appendCharacter("6"); break; case 7: appendCharacter("7"); break; case 8: appendCharacter("8"); break; case 9: appendCharacter("9"); break; case 10: String text = passwordEditText.getText().toString(); if (text.length() > 0) { passwordEditText.setText(text.substring(0, text.length() - 1)); } break; } if (passwordEditText.getText().toString().length() == 4) { processDone(false); } } }); numberFrameLayouts.add(frameLayout); } for (int a = 10; a >= 0; a--) { FrameLayout frameLayout = numberFrameLayouts.get(a); numbersFrameLayout.addView(frameLayout); layoutParams = (LayoutParams) frameLayout.getLayoutParams(); layoutParams.width = AndroidUtilities.dp(100); layoutParams.height = AndroidUtilities.dp(100); layoutParams.gravity = Gravity.TOP | Gravity.LEFT; frameLayout.setLayoutParams(layoutParams); } }
From source file:com.zhongsou.souyue.ui.indicator.SuberPageIndicator.java
private void addTab(int index, CharSequence text, int iconResId) { final TabView tabView = new TabView(getContext()); tabView.mIndex = index;// ww w .j av a 2 s .c o m tabView.setFocusable(true); tabView.setOnClickListener(mTabClickListener); tabView.setText(text); /*if (iconResId != 0) { tabView.setCompoundDrawablesWithIntrinsicBounds(0, iconResId, 0, 0); }*/ LinearLayout.LayoutParams parmas = new LinearLayout.LayoutParams(0, MATCH_PARENT, 1); parmas.gravity = Gravity.CENTER_HORIZONTAL; tabView.setGravity(Gravity.CENTER); mTabLayout.addView(tabView, parmas); }
From source file:it.redturtle.mobile.apparpav.MeteogramAdapter.java
/** * DOUBLE TITLE ROW// w ww. j a va 2 s . c o m * @param att * @param linear * @return */ public LinearLayout getDoubleTitleRow(Map<String, String> att, LinearLayout linear) { LinearLayout container_layout = new LinearLayout(context); container_layout.setMinimumHeight(30); container_layout .setBackgroundDrawable(context.getResources().getDrawable(R.drawable.view_shape_meteo_blue)); container_layout.setVerticalGravity(Gravity.CENTER); container_layout.setOrientation(LinearLayout.HORIZONTAL); LinearLayout.LayoutParams value_params = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, 0.3f); TextView tx = new TextView(context); tx.setText(""); tx.setTextColor(Color.rgb(66, 66, 66)); container_layout.addView(tx, value_params); LinearLayout.LayoutParams ltext1 = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, 0.35f); TextView t1 = new TextView(context); t1.setText(att.get("value1")); t1.setTextSize(11); t1.setGravity(Gravity.CENTER_HORIZONTAL); t1.setPadding(2, 0, 0, 2); t1.setTextColor(Color.rgb(255, 255, 255)); container_layout.addView(t1, ltext1); LinearLayout.LayoutParams ltext2 = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, 0.35f); TextView t2 = new TextView(context); t2.setText(att.get("value2")); t2.setTextSize(11); t2.setGravity(Gravity.CENTER_HORIZONTAL); t2.setPadding(2, 0, 0, 2); t2.setTextColor(Color.rgb(255, 255, 255)); container_layout.addView(t2, ltext2); linear.addView(container_layout); return linear; }
From source file:org.catnut.ui.HelloActivity.java
private void init() { setContentView(R.layout.about);//ww w . j a v a 2s . c o m mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setOnPageChangeListener(new PagerListener()); mImages = new ArrayList<Image>(); mPagerAdapter = new Gallery(); mViewPager.setAdapter(mPagerAdapter); mViewPager.setPageTransformer(true, new PageTransformer.DepthPageTransformer()); if (mTargetFromGrid != null) { mImages.add(mTargetFromGrid); mPagerAdapter.notifyDataSetChanged(); } mAbout = findViewById(R.id.about); mFantasyDesc = (TextView) findViewById(R.id.description); mFantasyDesc.setMovementMethod(LinkMovementMethod.getInstance()); ActionBar bar = getActionBar(); TextView about = (TextView) findViewById(R.id.about_body); TextView version = (TextView) findViewById(R.id.app_version); TextView appName = (TextView) findViewById(R.id.app_name); TextView weiboApp = (TextView) findViewById(R.id.weibo_app); weiboApp.setText(R.string.weibo_app); appName.setText(R.string.app_name); TextView appDesc = (TextView) findViewById(R.id.app_desc); appDesc.setText(R.string.app_desc); if (CatnutApp.getBoolean(R.string.pref_fantasy_say_salutation, R.bool.default_fantasy_say_salutation)) { version.setText(getString(R.string.about_version_template, getString(R.string.version_name))); int n = (int) (Math.random() * 101); if (0 < n && n < 35) { bar.setTitle(R.string.fantasy); about.setText(Html.fromHtml(getString(R.string.about_body))); about.setMovementMethod(LinkMovementMethod.getInstance()); } else { bar.setTitle(R.string.fantasy); about.setText(Html.fromHtml(getString(R.string.salutation))); about.setGravity(Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL); } } else { mAbout.setVisibility(View.GONE); } loadImage(); mConnectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); if (mApp.getPreferences().getBoolean(getString(R.string.enable_analytics), true)) { mTracker = EasyTracker.getInstance(this); } }
From source file:com.android.contacts.list.ContactsUnavailableFragment.java
/** * Set the message to be shown if no data is available for the selected tab * * @param resId - String resource ID of the message , -1 means view will not be visible *//*from w ww.java 2 s . com*/ public void setTabInfo(int resId, int callerTab) { mNoContactsMsgResId = resId; mLastTab = callerTab; if ((mMessageView != null) && (mProviderStatus != null) && mProviderStatus.equals(ProviderStatusCompat.STATUS_EMPTY)) { if (resId != -1) { mMessageView.setText(mNoContactsMsgResId); mMessageView.setGravity(Gravity.CENTER_HORIZONTAL); mMessageView.setVisibility(View.VISIBLE); if (callerTab == TabState.FAVORITES) { mImageView.setImageResource(R.drawable.ic_star_black_128dp); mProgress.setVisibility(View.GONE); updateButtonVisibilty(View.GONE); } else if (callerTab == TabState.ALL) { mImageView.setImageResource(R.drawable.ic_person_black_128dp); updateButtonVisibilty(View.VISIBLE); } } else { mMessageView.setVisibility(View.GONE); } } }