Mirkoddd / TabBarView

An Android Library to help you create actionbar tabs like "Capitaine train" app by Cyril Mottier
504 stars 94 forks source link

Set LayoutParams for Android 5.0 Toolbar #4

Open jaredrummler opened 9 years ago

jaredrummler commented 9 years ago

The Android 5.0 Toolbar adds extra padding, causing TabBarView to not match parent.

lollipop-tbv

Adding the following after calling super(context, attrs, defStyle); in TabBarView fixes the issue:

setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                LinearLayout.LayoutParams.MATCH_PARENT));

The material design guidelines show that no dividers should be used in tabs. I suggest you remove the dividers to match the new guidelines.

Mirkoddd commented 9 years ago

Hello Jared (you are one of my favourites devs) , thanks for pointing me to this bug. A quick fix would be:

private static int ab;

public TabBarView(Context context) {
    this(context, null);
}

public TabBarView(Context context, AttributeSet attrs) {
    this(context, attrs, ab);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        ab = 0;
    }else{
        ab = android.R.attr.actionBarTabBarStyle;
    }

}

for dividers;

public TabBarView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                LinearLayout.LayoutParams.MATCH_PARENT));

    }
         . . .
}

for the strip.

But I see there s no more highlight on press and text color is out of sync with the theme. I will fix it asap, thanks again

IgorGanapolsky commented 9 years ago

Has Toolbar and Material Design been implemented in this project yet? Or is still using the old ActionBar...

indrora commented 9 years ago

Any progress?