Skip to content

Commit 584834f

Browse files
committed
增强EasyIndicator的功能,支持Indicator样式自定义
1 parent 182c189 commit 584834f

File tree

6 files changed

+165
-83
lines changed

6 files changed

+165
-83
lines changed

app/src/main/java/com/xuexiang/xuidemo/fragment/components/tabbar/EasyIndicatorFragment.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ public class EasyIndicatorFragment extends BaseFragment {
4949

5050
@BindView(R.id.easy_indicator1)
5151
EasyIndicator mEasyIndicator1;
52+
@BindView(R.id.easy_indicator2)
53+
EasyIndicator mEasyIndicator2;
5254

5355
@BindView(R.id.easy_indicator)
5456
EasyIndicator mEasyIndicator;
@@ -128,6 +130,8 @@ private void initIndicatorNoViewPager() {
128130
mEasyIndicator1.setTabTitles(ContentPage.getPageNames());
129131
mEasyIndicator1.setOnTabClickListener((title, position) -> XToastUtils.toast("点击了" + title));
130132

133+
134+
mEasyIndicator2.setTabTitles(ContentPage.getPageNames());
131135
}
132136

133137
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?xml version="1.0" encoding="utf-8"?><!--
2+
~ Copyright (C) 2021 xuexiangjys(xuexiangjys@163.com)
3+
~
4+
~ Licensed under the Apache License, Version 2.0 (the "License");
5+
~ you may not use this file except in compliance with the License.
6+
~ You may obtain a copy of the License at
7+
~
8+
~ http://www.apache.org/licenses/LICENSE-2.0
9+
~
10+
~ Unless required by applicable law or agreed to in writing, software
11+
~ distributed under the License is distributed on an "AS IS" BASIS,
12+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
~ See the License for the specific language governing permissions and
14+
~ limitations under the License.
15+
~
16+
-->
17+
18+
<shape xmlns:android="http://schemas.android.com/apk/res/android"
19+
android:shape="rectangle">
20+
21+
<!--left to right-->
22+
<gradient
23+
android:angle="45"
24+
android:endColor="#FF6100"
25+
android:startColor="#FFD3B0" />
26+
27+
<corners android:radius="3dp" />
28+
29+
</shape>
30+
31+

app/src/main/res/layout/fragment_easy_indicator.xml

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,38 @@
2525
android:layout_width="match_parent"
2626
android:layout_height="wrap_content"
2727
android:layout_gravity="center_horizontal"
28-
app:indicator_line_show="true"
29-
app:indicator_line_height="2dp"
3028
app:indicator_height="42dp"
29+
app:indicator_line_height="2dp"
30+
app:indicator_line_show="true"
3131
app:indicator_textSize="14sp"
3232
app:indicator_width="0dp" />
3333

3434
<com.xuexiang.xui.widget.tabbar.EasyIndicator
35-
android:id="@+id/easy_indicator"
35+
android:id="@+id/easy_indicator2"
3636
android:layout_width="match_parent"
3737
android:layout_height="wrap_content"
38+
android:layout_gravity="center_horizontal"
3839
android:layout_marginTop="10dp"
39-
app:indicator_line_show="true"
40-
app:indicator_line_height="3dp"
4140
app:indicator_height="42dp"
41+
app:indicator_line_height="5dp"
42+
app:indicator_line_res="@drawable/shape_indicator_line"
43+
app:indicator_line_show="true"
44+
app:indicator_line_width="30dp"
45+
app:indicator_selected_color="#FF6100"
4246
app:indicator_textSize="14sp"
43-
app:indicator_width="0dp" />
47+
app:indicator_vertical_line_h="30dp"
48+
app:indicator_vertical_line_w="1dp"
49+
app:indicator_width="300dp" />
50+
51+
<com.xuexiang.xui.widget.tabbar.EasyIndicator
52+
android:id="@+id/easy_indicator"
53+
android:layout_width="match_parent"
54+
android:layout_height="wrap_content"
55+
android:layout_marginTop="10dp"
56+
app:indicator_height="42dp"
57+
app:indicator_line_height="3dp"
58+
app:indicator_line_show="true"
59+
app:indicator_textSize="14sp" />
4460

4561
<androidx.viewpager.widget.ViewPager
4662
android:id="@+id/view_pager"

0 commit comments

Comments
 (0)