Reputation: 8408
I am trying to create a sliding tabs app like the one in the screenshot below although due to the lack of samples available, this one is the closest I could find for what I want to achieve.
I would be very grateful if anybody could help me with following:
All help would be very much appreciated as there is literally no sample project out there that does what I want to achieve.
The link to the sample project that I intend to modify is below.
LINK: astuetz/PagerSlidingTabStrip · GitHub
Tabs
slidingTabs & my_tab_text_view
Upvotes: 0
Views: 1249
Reputation: 12977
well for fragments of your own did you have a look at ViewPager
? http://developer.android.com/training/animation/screen-slide.html
Also have a look at android sample code: https://developer.android.com/samples/SlidingTabsBasic/index.html
for controlling the actionBar: have a look at the new ToolBar api https://chris.banes.me/2014/10/17/appcompat-v21/
after that if you still have questions you are welcome to ask
slidingTabLayout = (SlidingTabLayout) findViewById(R.id.sliding_tabs);
slidingTabLayout.setDividerColors(getResources().getColor(android.R.color.transparent));
slidingTabLayout.setSelectedIndicatorColors(getResources().getColor(android.R.color.white));
add this method to SlidingTabLayout
public class SlidingTabLayout extends HorizontalScrollView {
/**
* #####################Add THIS METHOD ############
*
* @param layoutResId Layout id to be inflated
* @param textViewId id of the {@link TextView} in the inflated view
*/
public void setCustomTabView (int layoutResId, int textViewId) {
mTabViewLayoutId = layoutResId;
mTabViewTextViewId = textViewId;
}
...
}
from your activity:
public void onCreate(){
slidingTabs.setCustomTabView(0, R.layout.my_tab_text_view)
}
where my_tab_text_view is a layout file:
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"/>
just make sure that width is 0 and weight is 1
Upvotes: 1