Skip to content

Commit

Permalink
Merge branch 'iss68_iss70' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
jpardogo committed Jun 1, 2015
2 parents b853495 + bde31ed commit 679a74e
Show file tree
Hide file tree
Showing 14 changed files with 511 additions and 413 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@ Change Log
Version 1.1.0 *(?)*
---------------------------------
* Bug fixes
* Rename some custom attributes.
* Default ripple effect selector in 21+
* Default sans-serif-medium tab's text in API 21+
* app:pstsTextFontFamily for overriding the typeface from the XML. The attribute works exactly like android:fontFamily for TextViews.
* setTypeface(Typeface typeface, int style) deprecated for the new setTypeface(Typeface typeface, int style, int selectedStyle)
* Remove custom attire `pstsTextColorSelected ` and `pstsTextSelectedStyle`.
* `pstsTabTextColor` will handle the tab text color states.
* `pstsTabTextSize` will handle the tab text size.
* Callbacks for selection/deselection of tabs passing the tab view as parameter when custom tabs are use.

Version 1.0.9 *(22-02-2015)*
---------------------------------
Expand Down
74 changes: 42 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,17 @@ Android Support Library.

# Usage

*For a working implementation of this project see the `sample/` folder.*
For a working implementation of this project see the `sample/` folder.

1. Include the following dependency in your `build.gradle` file.
1.Include the following dependency in your `build.gradle` file.

```groovy
compile 'com.jpardogo.materialtabstrip:library:1.0.9'
compile 'com.jpardogo.materialtabstrip:library:1.1.0'
```
Or add the library as a project. I tried to send a pull request, but looks like the original
developer doesn't maintain it anymore.

2. Include the `PagerSlidingTabStrip` widget in your layout. This should usually be placed
above the `ViewPager` it represents.
Or add the library as a project. I tried to send a pull request, but looks like the original developer doesn't maintain it anymore.

2.Include the `PagerSlidingTabStrip` widget in your layout. This should usually be placed above the `ViewPager` it represents.

```xml
<com.astuetz.PagerSlidingTabStrip
Expand All @@ -29,8 +28,7 @@ Android Support Library.
android:background="?attr/colorPrimary" />
```

3. In your `onCreate` method (or `onCreateView` for a fragment), bind the
widget to the `ViewPager`:
3.In your `onCreate` method (or `onCreateView` for a fragment), bind the widget to the `ViewPager`:

```java
// Initialize the ViewPager and set an adapter
Expand All @@ -42,14 +40,20 @@ Android Support Library.
tabs.setViewPager(pager);
```

5. If your adapter implements the interface `CustomTabProvider` you can paste your custom tab view/s.
###That's all you need to do, but if you want to use your own tabs, then....

4.If your adapter implements the interface `CustomTabProvider` you can paste your custom tab view/s.

- In case the the view returned contains the id `R.id.psts_tab_title`, this view should be a `TextView` and
will be used to placed the title. If you don't want the library manage your TextView title for the tab,
use a different id than `R.id.psts_tab_title` in your tab layout.
will be used to placed the title and set the view state (pressed/selected/default).

- If you don't want the library manage your TextView title for the tab, use a different id than `R.id.psts_tab_title` in your tab layout.

- The interface provide callbacks for selection and unselection of tabs as well.

- If your adapter doesn't implement the interface `CustomTabProvider` the default tab will be used, which is a `TextView` with id `R.id.psts_tab_title`).

4. *(Optional)* If you use an `OnPageChangeListener` with your view pager
5.*(Optional)* If you use an `OnPageChangeListener` with your view pager
you should set it in the widget rather than on the pager directly.

```java
Expand All @@ -61,47 +65,53 @@ Android Support Library.

From theme:

* `android:textColorPrimary` value (from your theme) will be applied automatically to the tab's text color (Selected tab with 255 alpha and non selected tabs with 150 alpha), underlineColor, dividerColor and indicatorColor, if the values are not defined on the xml layout.
* `android:textColorPrimary` value (from your theme) will be applied automatically to the tab's text color (Selected tab with 255 alpha and non selected tabs with 150 alpha), underlineColor, dividerColor and indicatorColor, if the values are not defined on the xml layout.

Notes about some of the native attributes:

* `android:textColor` Non-selected tabs text color. If you DO define `textColor` It will be apply to **NON selected** tabs and **NO ALPHA** will be applied to them, **the color you define is the one you will see**. If you want to define a half transparent color in `textColor`, you can pass #80FFFFFF (e.g. half transparent white).
* `android:textSize` Tab text size
* `android:paddingLeft` or `android:paddingRight` layout padding. If you apply both, they should be balanced. PR #69 has a good explanation of this behaviour.
* `android:paddingLeft` or `android:paddingRight` layout padding. If you apply both, they should be balanced. Check issue [#69](https://github.com/jpardogo/PagerSlidingTabStrip/pull/69) for more information.

Custom attributes:

* `pstsIndicatorColor` Color of the sliding indicator. `textPrimaryColor` will be it's default color value.
* `pstsIndicatorHeight`Height of the sliding indicator.
* `pstsUnderlineColor` Color of the full-width line on the bottom of the view. `textPrimaryColor` will be it's default color value.
* `pstsUnderlineHeight` Height of the full-width line on the bottom of the view.
* `pstsTextAlpha` Set the text alpha transparency for non selected tabs. Range 0..255. 150 is it's default value. It **WON'T** be used if `textColor` is defined in the layout. If `textColor` is **NOT** defined, It will be applied to the non selected tabs.
* `pstsTextColorSelected` Set selected tab text color. `textPrimaryColor` will be it's default color value.
* `pstsTextStyle` Set the text style, default normal on API 21, bold on older APIs.
* `pstsTextSelectedStyle` Set the text style of the selected tab, default normal on API 21, bold on older APIs.
* `pstsTextFontFamily` Set the font family name. Default `sans-serif-medium` on API 21, `sans-serif` on older APIs.
* `pstsTextAllCaps` If true, all tab titles will be upper case, default true.
* `pstsDividerColor` Color of the dividers between tabs. `textPrimaryColor` will be it's default color value.
* `pstsDividerPadding` Top and bottom padding of the dividers.
* `pstsDividerWidth` Stroke width of divider line, defaults to 0.
* `pstsIndicatorHeight`Height of the sliding indicator.
* `pstsTabPaddingLeftRight` Left and right padding of each tab.
* `pstsScrollOffset` Scroll offset of the selected tab.
* `pstsTabBackground` Background drawable of each tab, should be a StateListDrawable.
* `pstsDividerPadding` Top and bottom padding of the dividers.
* `pstsShouldExpand` If set to true, each tab is given the same weight, default false.
* `pstsScrollOffset` Scroll offset of the selected tab.
* `pstsPaddingMiddle` If true, the tabs start at the middle of the view (Like Newsstand google app).
* `pstsTabPaddingLeftRight` Left and right padding of each tab.
* `pstsTabBackground` Background drawable of each tab, should be a StateListDrawable.
* `pstsTabTextSize` Tab text size (sp).
* `pstsTabTextColor` Tab text color that can either be a color (text color won't changed) or a selector with a color per state: pressed (tab pressed), selected (tab active), default (active non active). The order of states in the selector is important. Check issue [#68](https://github.com/jpardogo/PagerSlidingTabStrip/pull/70) for more information.
* `pstsTabTextStyle` Set the text style, default normal on API 21, bold on older APIs.
* `pstsTabTextAllCaps` If true, all tab titles will be upper case, default true.
* `pstsTabTextAlpha` Set the text alpha transparency for non selected tabs. Range 0..255. 150 is it's default value. It **WON'T** be used if `pstsTabTextColor` is defined in the layout. If `pstsTabTextColor` is **NOT** defined, It will be applied to the non selected tabs.
* `pstsTabTextFontFamily` Set the font family name. Default `sans-serif-medium` on API 21, `sans-serif` on older APIs.

Almost all attributes have their respective getters and setters to change them at runtime. To change dynamically `pstsTabTextFontFamily` and `pstsTabTextStyle` you can call:

*Almost all attributes have their respective getters and setters to change them at runtime*. Please open an issue if you find any are missing.
* `public void setTypeface(Typeface typeface, int style)`. It can be used to define custom fonts in default tabs. Otherwise you can use custom tabs with `CustomTabProvider`.

Please open an issue if you find any are missing.

# Developed By

* Javier Pardo de Santayana Gomez - [jpardogo.com](http://www.jpardogo.com) - <[email protected]>
* Andreas Stuetz - <[email protected]>
* Check contributors list.
* And contributors.

### Credits
# Contributions

* [Kirill Grouchnikov](https://plus.google.com/108761828584265913206/posts) - Author of [an explanation post on Google+](https://plus.google.com/108761828584265913206/posts/Cwk7joBV3AC)
* Please, read the README file before opening an issue, thanks.
* Please, all the Pull Request must be sent to the dev branch, thanks..

# Credits

* [Kirill Grouchnikov](https://plus.google.com/108761828584265913206/posts) - Author of [an explanation post on Google+](https://plus.google.com/108761828584265913206/posts/Cwk7joBV3AC)

# License

Expand Down
24 changes: 10 additions & 14 deletions library/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,27 @@

<declare-styleable name="PagerSlidingTabStrip">
<attr name="pstsIndicatorColor" format="color" />
<attr name="pstsIndicatorHeight" format="dimension" />
<attr name="pstsUnderlineColor" format="color" />
<attr name="pstsUnderlineHeight" format="dimension" />
<attr name="pstsDividerColor" format="color" />
<attr name="pstsDividerWidth" format="dimension" />
<attr name="pstsIndicatorHeight" format="dimension" />
<attr name="pstsUnderlineHeight" format="dimension" />
<attr name="pstsDividerPadding" format="dimension" />
<attr name="pstsTabPaddingLeftRight" format="dimension" />
<attr name="pstsScrollOffset" format="dimension" />
<attr name="pstsTabBackground" format="reference" />
<attr name="pstsShouldExpand" format="boolean" />
<attr name="pstsTextAllCaps" format="boolean" />
<attr name="pstsPaddingMiddle" format="boolean" />
<attr name="pstsTextColorSelected" format="color" />
<attr name="pstsTextAlpha" format="integer" />
<attr name="pstsTextStyle">
<flag name="normal" value="0x0" />
<flag name="bold" value="0x1" />
<flag name="italic" value="0x2" />
</attr>
<attr name="pstsTextSelectedStyle">
<attr name="pstsTabPaddingLeftRight" format="dimension" />
<attr name="pstsTabBackground" format="reference" />
<attr name="pstsTabTextSize" format="dimension" />
<attr name="pstsTabTextColor" format="reference" />
<attr name="pstsTabTextStyle" format="reference">
<flag name="normal" value="0x0" />
<flag name="bold" value="0x1" />
<flag name="italic" value="0x2" />
</attr>
<attr name="pstsTextFontFamily" format="string" />
<attr name="pstsTabTextAllCaps" format="boolean" />
<attr name="pstsTabTextAlpha" format="integer" />
<attr name="pstsTabTextFontFamily" format="string" />
</declare-styleable>

</resources>
Loading

0 comments on commit 679a74e

Please sign in to comment.