AnotherViewPager


Source link: https://github.com/kristiyanP/anotherViewPager

AnotherViewPager

Include in your project

compile 'io.kri:anotherViewPager:1.0.1'

How to use

create layout_page1.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:app="http://schemas.android.com/apk/res-auto"
  xmlns:tools="http://schemas.android.com/tools"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:orientation="vertical">

<TextView

android:id="+@id/title"

android:text="page1"

android:layout_width="wrap_content"

android:layout_height="wrap_content"/>  </LinearLayout>

create activity_main.xml

<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:app="http://schemas.android.com/apk/res-auto"
  xmlns:tools="http://schemas.android.com/tools"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:orientation="vertical"
  tools:context="io.kri.anotherViewPager.app.MainActivity">

<io.kri.anotherViewPager.TabbedViewPager

android:id="@+id/viewPager"

android:layout_width="match_parent"

android:layout_height="wrap_content"

app:tabSelectedFont="@font/quicksand_bold" />  </LinearLayout>

In Java or in Kotlin (see below)

Create viewPager item

public class Page1 extends TabbedViewPagerItem{

  @Override
  public String getTitle() {

return "Title Page1";
  
}

@Override
  public int getLayoutResId() {

return R.layout.layout_page1;
  
}

@Override
  protected void bind(Context context, ViewGroup parent) {

// customize the look programatically

TextView title = parent.findViewById(R.id.title);

title.setTextColor(Color.BLUE);

  
}
 
}

Set MainActivity.java

public class MainActivity extends AppCompatActivity {

  @Override
  protected void onCreate(@Nullable Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

 ViewPager viewPager = findViewById(R.id.viewPager);

TabbedViewPagerAdapter adapter = new TabbedViewPagerAdapter()

  .addItem(new Page1());

 viewPager.setAdapter(adapter);

  
}
 
}

In Kotlin

Create viewPager item

class Page1 : TabbedViewPagerItem() {

override fun getTitle(): String {

return "Title Page1"
  
}

override fun getLayoutResId(): Int {

return R.layout.page_1
  
}

override fun bind(context: Context, parent: ViewGroup) {

 // customize the look programatically

val title = findViewById(R.id.title)

title.setBackgroundColor(Color.BLUE)
  
}
 
}

Set MainAcitivty

class MainActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {

super.onCreate(savedInstanceState)

setContentView(R.layout.activity_main)

 val adapter = TabbedViewPagerAdapter()

  .addItem(Page1())

 viewPager.setAdapter(adapter)
  
}
 
}

Style customization

Further Cutomization

possible attributes to set to the tabbedViewPager

<attr name="tabItemsMarginStart" format="dimension" /> <attr name="tabItemsMarginEnd" format="dimension" /> <attr name="tabItemsMarginBottom" format="dimension" /> <attr name="tabItemsMarginTop" format="dimension" /> <attr name="tabSelectedFont" format="reference"/> <attr name="tabDefaultFont" format="reference"/> <attr name="tabSelectedTextColor" />

More customizations

If you want to have another style just implement the following styles, they will overwrite the default ones

<style name="TabbedViewPagerStyle"> <!-- style for the whole viewPager !--> </style>  <style name="TabbedViewPagerTabTextStyle"> <!-- style for the title !--> </style>

Resources

Android Starter is a starter project which implements MVP Pattern. It includes libraries:

  • RxJava2
  • RxAndroid
  • Dagger2
  • Butterknife
  • Crashlytics
  • Timber
  • GreenDao
  • Realm
  • Retrofit
  • OkHttp
  • Gson
  • Picasso

Implementation of List Item from Material Design guidelines.

Android Toolbar with marqueeable title / subtitle.

Shareable is a small android library to help implement direct share and social media actions into your android app. For example if you want to share something specifically to Twitter or Facebook.

The API is design to allow you to specify specific social channels to share to using the Builder design pattern. If the app is not available the default is to use all Intent.ACTION_SEND apps on the phone.

ColorPickerDialog is an Android Library providing color picker dialog for single color or multi color selection from the ArrayList of colors provided by developer.

A delightful progress animation that you'll fall in love with, very easily.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes