问题描述
我使用谷歌的SlidingTabLayout在我看来,但我想要的图标添加到标签。我使用该http://developer.android.com/samples/SlidingTabsBasic/src/com.example.android.common/view/SlidingTabLayout.html任何人都可以请帮助?
无效setUpPager(查看视图){
mViewPager =(ViewPager)view.findViewById(R.id.viewpager);
mViewPager.setAdapter(新TabsPagerAdapter(getActivity()));
mSlidingTabLayout =(SlidingTabLayout)view.findViewById(R.id.sliding_tabs);
mSlidingTabLayout.setViewPager(mViewPager);
}
下面是我的xml:
< LinearLayout中的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:layout_width =match_parent
机器人:layout_height =match_parent
机器人:方向=垂直>
< android.common.view.SlidingTabLayout
机器人:ID =@ + ID / sliding_tabs
机器人:layout_width =match_parent
机器人:layout_height =WRAP_CONTENT/>
< android.support.v4.view.ViewPager
机器人:ID =@ + ID / viewpager
机器人:layout_width =match_parent
机器人:layout_height =0px
机器人:layout_weight =1
机器人:背景=@机器人:彩色/白/>
< / LinearLayout中>
使用 mSlidingTabLayout.setCustomTabView(INT layoutResId,诠释textViewId)
膨胀的自定义布局 SlidingTabLayout
设置页的意见。
在 SlidingTabLayout
试图填充选项卡条,初步查找任何指定的布局资源膨胀。否则,充气默认选项卡视图。
I am using google's SlidingTabLayout in my view, but i want to add icons to the tabs. I'm using this http://developer.android.com/samples/SlidingTabsBasic/src/com.example.android.common/view/SlidingTabLayout.htmlCan anyone please help?
void setUpPager(View view){
mViewPager = (ViewPager) view.findViewById(R.id.viewpager);
mViewPager.setAdapter(new TabsPagerAdapter(getActivity()));
mSlidingTabLayout = (SlidingTabLayout) view.findViewById(R.id.sliding_tabs);
mSlidingTabLayout.setViewPager(mViewPager);
}
Here is my xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.common.view.SlidingTabLayout
android:id="@+id/sliding_tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<android.support.v4.view.ViewPager
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_weight="1"
android:background="@android:color/white"/>
</LinearLayout>
Use mSlidingTabLayout.setCustomTabView(int layoutResId, int textViewId)
to inflate a custom layout for the SlidingTabLayout
tab views.
When SlidingTabLayout
tries to populate the tab strips, initially looks for any specified layout resource to inflate. Otherwise, it inflates default tab view.
这篇关于Android的SlidingTabLayout的图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!