我们经常使用一些手机应用,看到别人的透明层感觉非常好看,那么是怎么实现的呢?今天小编就来分享一下这些Android透明指示层
Android透明指示层,现在用到这种效果的app好多,只需要改改布局就可以,给大家提供个思路,共同进步
这样的一些界面效果都是不需要我们再重新编写的,它们属于所称的“民间控件”,如果我们在开发需要呈现这样的一些效果 ,只需要去下载它的库,然后导入到我们的项目里,在项目里直接用它就可以了,
一:在布局文件中声明要用的这个控件
[html] view plaincopy
<com.viewpagerindicator.TitlePageIndicator
android:id="@+id/titles"
android:layout_height="wrap_content"
android:layout_width="fill_parent" />
二:绑定控件:
[java] view plaincopy
//Set the pager with an adapter
ViewPager pager = (ViewPager)findViewById(R.id.pager);
pager.setAdapter(new TestAdapter(getSupportFragmentManager()));
//Bind the title indicator to the adapter
TitlePageIndicator titleIndicator = (TitlePageIndicator)findViewById(R.id.titles);
titleIndicator.setViewPager(pager);
三:设置监听事件
[java] view plaincopy
titleIndicator.setOnPageChangeListener(mPageChangeListener);
一个完整的使用示例:
[java] view plaincopy
public class DemoActivity extends FragmentActivity {
DemoFragmentAdapter mAdapter;
ViewPager mPager;//该类为我们引用库中的
PageIndicator mIndicator;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity);
mAdapter = new DemoFragmentAdapter(getSupportFragmentManager());//自定义的一个适配器
mPager = (ViewPager)findViewById(R.id.pager);
mPager.setAdapter(mAdapter);
//UnderlinePageIndicator 该类为项目中的另一个自定义类
UnderlinePageIndicator indicator = (UnderlinePageIndicator)findViewById(R.id.indicator);
indicator.setViewPager(mPager);
indicator.setFades(false);
mIndicator = indicator;
}
}
140.5M / 09-05
76.4M / 03-25
55M / 06-05
237.9M / 04-13
900.9M / 03-02
96.2M / 07-06
311.2M / 07-06
335M / 07-06
200M / 07-06
413.8M / 07-06
484.7M / 09-27
165.4M / 09-05
353.9M / 06-05
131.8M / 04-13
195.6M / 03-03
45.6M / 09-08
665.2M / 07-06
2.84G / 07-06
93M / 07-06
338.3M / 07-06
1.38G / 07-26
488.3M / 07-16
109.8M / 06-03
142M / 01-08
1.2M / 11-23
548.8M / 04-13
1.6M / 04-13
1.48G / 03-18
646.6M / 03-03
133.7M / 03-03
110.5M / 09-05
33.4M / 09-05
325.8M / 08-12
60M / 04-29
254M / 04-25
659M / 04-23
1M / 12-26
253.4M / 12-08
253M / 12-08
1.19G / 11-16
369M / 09-22
181.5M / 09-22
201.2M / 09-05
488.3M / 07-16
248.9M / 12-08
248.9M / 12-08
100.6M / 03-06
148.9M / 03-06
1.12G / 07-06
1.25G / 07-06
126.7M / 02-04
1.76G / 09-22
1.92G / 04-17
201.5M / 04-13
7.31G / 07-01
94.3M / 07-06
2.48G / 07-06
7.63G / 07-06
1M / 07-06
778.1M / 07-06
561.8M / 07-11
72M / 07-06
548.7M / 07-06
1.00G / 07-06
9.13G / 07-06
126.2M / 07-06
72M / 07-06
105.1M / 07-06
132M / 07-06
132M / 07-06