代码已经整理好,效果如下图:
code1:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
<com.ui.widget.UnAnimTabLayout
android:id=
"@+id/tab"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_gravity=
"center_vertical"
android:clipToPadding=
"false"
android:paddingLeft=
"5dp"
app:tabBackground=
"@drawable/tab_selector_green"
app:tabIndicatorColor=
"@android:color/white"
app:tabIndicatorHeight=
"0dp"
app:tabMaxWidth=
"0dp"
app:tabMinWidth=
"0dp"
app:tabMode=
"scrollable"
app:tabSelectedTextColor=
"@color/white"
app:tabTextAppearance=
"@style/tab_text_size"
app:tabTextColor=
"@color/black_common"
/>
<style name=
"tab_text_size"
>
<item name=
"android:textSize"
>28dp</item>
</style>
<com.widget.UnAnimTabLayout
android:id=
"@+id/tab_add"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:clipToPadding=
"false"
android:layout_marginLeft=
"@dimen/x20"
android:layout_marginRight=
"@dimen/x20"
app:tabIndicatorColor=
"@color/blue3"
app:tabIndicatorHeight=
"@dimen/x3"
app:tabMaxWidth=
"0dp"
app:tabMinWidth=
"0dp"
app:tabMode=
"scrollable"
app:tabSelectedTextColor=
"@color/blue3"
app:tabTextAppearance=
"@style/tab_text_size"
app:tabTextColor=
"@color/black_common"
/>
|
code2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
mCateTabLayout.addOnTabSelectedListener(
new
TabSelectAdapter() {
@Override
public
void
onTabSelected(TabLayout.Tab tab) {
TabUtils.tabSelect(mCateTabLayout, tab);
int
tag = (
int
) tab.getTag();
if
(tag == -
1
) {
return
;
}
if
(!once_footer) {
once_footer =
true
;
return
;
}
footer_id = tag;
//请求数据bufen
set_refresh_data();
}
});
mCateTabLayout.post(
new
Runnable() {
@Override
public
void
run() {
TabUtils.setIndicator(mCateTabLayout,
80
,
80
);
}
});
// 初始化
tab_add.removeAllTabs();
for
(FmNewFoodFenleiBean item : list_tab_add) {
tab_add.addTab(tab_add.newTab()
.setTag(item.getFood_category_id()).setText(item.getFood_category_name()));
}
|
图片1:
图片2:
图片3:
本文转自 吴雨声 51CTO博客,原文链接:http://blog.51cto.com/liangxiao/1963094,如需转载请自行联系原作者