<RelativeLayout
android:id="@+id/register_divider_layout"
android:layout_width="fill_parent"
android:layout_height="2dp" >
<View
android:id="@+id/register_divider"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/tab_unpressed" />
<View
android:id="@+id/register_divider_highlight"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:background="@drawable/tab_pressed" />
</RelativeLayout>
private void initImageView() {
mHighLightView = findViewById(R.id.register_divider_highlight);
RelativeLayout.LayoutParams params = (LayoutParams) mHighLightView.getLayoutParams();
DisplayMetrics dm = getResources().getDisplayMetrics();
mScreenW = dm.widthPixels; // 获取分辨率宽度
if (params == null) {
int height = (int) (2 * dm.density);
params = new RelativeLayout.LayoutParams(mScreenW / 2, height);
}
params.width = mScreenW / 2;
mHighLightView.setLayoutParams(params);
}
{
Animation animation = new TranslateAnimation(oneW * previousPage, oneW * currentPage, 0, 0);
animation.setFillAfter(true); // True:图片停在动画结束位置
animation.setDuration(300); //设置动画持续时间
animation.setRepeatCount(0); // 设置重复次数,这里不重复
// animation.setRepeatMode(Animation.REVERSE); // 设置反方向执行
mHighLightView.startAnimation(animation);
}