|
5 | 5 | TabViewBase, TabViewItemBase, itemsProperty, selectedIndexProperty, |
6 | 6 | tabTextColorProperty, tabBackgroundColorProperty, selectedTabTextColorProperty, |
7 | 7 | androidSelectedTabHighlightColorProperty, androidOffscreenTabLimitProperty, |
8 | | - fontSizeProperty, fontInternalProperty, View, layout, |
9 | | - traceCategory, traceEnabled, traceWrite, Color |
| 8 | + fontSizeProperty, fontInternalProperty, View, layout, traceCategory, traceEnabled, |
| 9 | + traceWrite, Color |
10 | 10 | } from "./tab-view-common" |
11 | 11 | import { textTransformProperty, TextTransform, getTransformedText } from "../text-base"; |
12 | 12 | import { fromFileOrResource } from "../../image-source"; |
@@ -367,36 +367,49 @@ export class TabView extends TabViewBase { |
367 | 367 |
|
368 | 368 | const context: android.content.Context = this._context; |
369 | 369 | const nativeView = new org.nativescript.widgets.GridLayout(context); |
370 | | - nativeView.addRow(new org.nativescript.widgets.ItemSpec(1, org.nativescript.widgets.GridUnitType.auto)); |
371 | | - nativeView.addRow(new org.nativescript.widgets.ItemSpec(1, org.nativescript.widgets.GridUnitType.star)); |
372 | | - |
| 370 | + const viewPager = new org.nativescript.widgets.TabViewPager(context); |
373 | 371 | const tabLayout = new org.nativescript.widgets.TabLayout(context); |
| 372 | + const lp = new org.nativescript.widgets.CommonLayoutParams(); |
| 373 | + const primaryColor = ad.resources.getPaletteColor(PRIMARY_COLOR, context); |
| 374 | + let accentColor = getDefaultAccentColor(context); |
| 375 | + |
| 376 | + lp.row = 1; |
| 377 | + |
| 378 | + if (this.androidTabsPosition === "top") { |
| 379 | + nativeView.addRow(new org.nativescript.widgets.ItemSpec(1, org.nativescript.widgets.GridUnitType.auto)); |
| 380 | + nativeView.addRow(new org.nativescript.widgets.ItemSpec(1, org.nativescript.widgets.GridUnitType.star)); |
| 381 | + |
| 382 | + viewPager.setLayoutParams(lp); |
| 383 | + } else { |
| 384 | + nativeView.addRow(new org.nativescript.widgets.ItemSpec(1, org.nativescript.widgets.GridUnitType.star)); |
| 385 | + nativeView.addRow(new org.nativescript.widgets.ItemSpec(1, org.nativescript.widgets.GridUnitType.auto)); |
| 386 | + |
| 387 | + tabLayout.setLayoutParams(lp); |
| 388 | + viewPager.setSwipePageEnabled(false); |
| 389 | + // set completely transparent accent color for tab selected indicator. |
| 390 | + accentColor = 0x00FFFFFF; |
| 391 | + } |
| 392 | + |
| 393 | + nativeView.addView(viewPager); |
| 394 | + (<any>nativeView).viewPager = viewPager; |
| 395 | + |
| 396 | + const adapter = new PagerAdapter(this); |
| 397 | + viewPager.setAdapter(adapter); |
| 398 | + (<any>viewPager).adapter = adapter; |
| 399 | + |
374 | 400 | nativeView.addView(tabLayout); |
375 | 401 | (<any>nativeView).tabLayout = tabLayout; |
376 | 402 |
|
377 | 403 | setElevation(nativeView, tabLayout); |
378 | 404 |
|
379 | | - const accentColor = getDefaultAccentColor(context); |
380 | 405 | if (accentColor) { |
381 | 406 | tabLayout.setSelectedIndicatorColors([accentColor]); |
382 | 407 | } |
383 | 408 |
|
384 | | - const primaryColor = ad.resources.getPaletteColor(PRIMARY_COLOR, context); |
385 | 409 | if (primaryColor) { |
386 | 410 | tabLayout.setBackgroundColor(primaryColor); |
387 | 411 | } |
388 | 412 |
|
389 | | - const viewPager = new android.support.v4.view.ViewPager(context); |
390 | | - const lp = new org.nativescript.widgets.CommonLayoutParams(); |
391 | | - lp.row = 1; |
392 | | - viewPager.setLayoutParams(lp); |
393 | | - nativeView.addView(viewPager); |
394 | | - (<any>nativeView).viewPager = viewPager; |
395 | | - |
396 | | - const adapter = new PagerAdapter(this); |
397 | | - viewPager.setAdapter(adapter); |
398 | | - (<any>viewPager).adapter = adapter; |
399 | | - |
400 | 413 | return nativeView; |
401 | 414 | } |
402 | 415 |
|
|
0 commit comments