android center align the selected tab in tablayout

I took a look into TabLayout and tabContentStart only sets padding for its first child -> SlidingTabStrip, so I set it manually on both sides: public class CenteringTabLayout extends TabLayout { public CenteringTabLayout(Context context) { super(context); } public CenteringTabLayout(Context context, AttributeSet attrs) { super(context, attrs); } public CenteringTabLayout(Context context, AttributeSet attrs, int defStyleAttr) { super(context, … Read more

Align a div to center

There is no float to center per se. If you want to center a block element inside another do this: <div id=”outer”> <div id=”inner”>Stuff to center</div> </div> with: #outer { width: 600px; } #inner { width: 250px; margin: 0 auto; } Now that won’t make the text wrap around it (like it would with a … Read more

Center Align title in action bar using styles in android.

Simple method to center ActionBarTitle without using custom layout for actionBar. But before that first hide up Icon as : myActionBar.setIcon(new ColorDrawable(Color.TRANSPARENT)); private void centerActionBarTitle() { int titleId = 0; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { titleId = getResources().getIdentifier(“action_bar_title”, “id”, “android”); } else { // This is the id is from your app’s generated R class … Read more