Changes

Jump to: navigation, search
m
Text replacement - "<google>BUY_ANDROID_STUDIO6</google>" to "<htmlet>androidstudio_a6</htmlet>"
<googlehtmlet>BUY_ANDROID_STUDIO6androidstudio_a6</googlehtmlet>
Switch to Design mode and select and delete the TextView from the layout. From the Palette, locate the Large Text widget and drag and drop it so that it is positioned into the center of the layout. Edit the text on the object so that it reads “Tab 1 Fragment” at which point the layout should match that of Figure 31-4:
<googlehtmlet>BUY_ANDROID_STUDIO6androidstudio_a6</googlehtmlet>
[[Image:android_studio_tab_layout_fragment1.png]]
Edit the TabPagerAdapter.java file so that it reads as follows:
<googlehtmlet>BUY_ANDROID_STUDIO6androidstudio_a6</googlehtmlet>
<pre>
package com.ebookfrenzy.tablayoutdemo;
tabLayout.addTab(tabLayout.newTab().setText("Tab 4 Item"));
</pre>
<googlehtmlet>BUY_ANDROID_STUDIO6androidstudio_a6</googlehtmlet>
A reference to the ViewPager instance in the layout file is then obtained and an instance of the TabPagerAdapter class created. Note that the code to create the TabPagerAdapter instance passes through the number of tabs that have been assigned to the TabLayout component. The TabPagerAdapter instance is then assigned as the adapter for the ViewPager and the TabLayout component added to the page change listener:
Figure 31-9
<googlehtmlet>BUY_ANDROID_STUDIO6androidstudio_a6</googlehtmlet>
Changing the property value to “center” will cause the items to be positioned relative to the center of the tab bar:
<googlehtmlet>BUY_ANDROID_STUDIO6androidstudio_a6</googlehtmlet>

Navigation menu