Open macoal opened 8 years ago
2016年9月3日10:16:45 近来工作不算繁忙,主要都是学习一些东西。 天天加班很累。一天。准备加一会儿班就走,但到下午6点才说,忽然说有任务,还要今天就解决(小公司就是好,任性)。就然说走,那就走。什么任务?引导页?不管。那就做吧。 直接亮代码 VectorActivity.java
2016年9月3日10:16:45
VectorActivity.java
public class VectorActivity extends AppCompatActivity implements ViewPager.OnPageChangeListener { //初始化导航页面资源 private static final int[] start = new int[]{R.drawable.start1, R.drawable.start1, R.drawable.start1, R.drawable.start1, R.drawable.start1}; private ImageView startButton; private LinearLayout ll; private ImageView[] dots; private int currentIndex; private int picNum; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); List<View> views = new ArrayList<>(); int[] pics; //隐藏标题栏 requestWindowFeature(Window.FEATURE_NO_TITLE); //定义全屏参数 int wflag = WindowManager.LayoutParams.FLAG_FULLSCREEN; //获得当前窗体对象 Window window = VectorActivity.this.getWindow(); //设置当前窗体为全屏显示 window.setFlags(wflag, wflag); setContentView(R.layout.activity_vector); LinearLayout.LayoutParams mParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT); ViewPager viewPager = (ViewPager) findViewById(R.id.vector_viewpager); pics = start; picNum = pics.length; for (int i : pics) { ImageView iv = new ImageView(this); iv.setScaleType(ImageView.ScaleType.FIT_XY); iv.setLayoutParams(mParams); iv.setScaleType(ImageView.ScaleType.FIT_XY); iv.setImageResource(i); views.add(iv); } initDots(); ViewPagerAdapter vpAdapter = new ViewPagerAdapter(views); if (viewPager != null) { viewPager.setAdapter(vpAdapter); viewPager.addOnPageChangeListener(this); } startButton = (ImageView) findViewById(R.id.vector_end_button); startButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //结束导航页面 finish(); } }); } //初始化导航下方的点 private void initDots() { ll = (LinearLayout) findViewById(R.id.ll); if (ll != null) { dots = new ImageView[picNum]; for (int i = 0; i < picNum; i++) { dots[i] = (ImageView) ll.getChildAt(i); dots[i].setSelected(false); dots[i].setVisibility(View.VISIBLE); dots[i].setTag(i); } currentIndex = 0; dots[currentIndex].setSelected(true); } } @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { } @Override public void onPageScrollStateChanged(int state) { } @Override public void onPageSelected(int position) { setCurDot(position); //判断是否到最后一页 if (position == picNum - 1) { ll.setVisibility(View.GONE); startButton.setVisibility(View.VISIBLE); } else { ll.setVisibility(View.VISIBLE); startButton.setVisibility(View.INVISIBLE); } } //设置当前页的点为选择状态 private void setCurDot(int positon) { if (positon < 0 || positon > picNum - 1 || currentIndex == positon) { return; } dots[positon].setSelected(true); dots[currentIndex].setSelected(false); currentIndex = positon; } private class ViewPagerAdapter extends PagerAdapter { private List<View> views; public ViewPagerAdapter(List<View> views) { this.views = views; } @Override public void destroyItem(ViewGroup arg0, int arg1, Object arg2) { arg0.removeView(views.get(arg1)); } @Override public int getCount() { if (views != null) { return views.size(); } return 0; } @Override public Object instantiateItem(ViewGroup arg0, int arg1) { arg0.addView(views.get(arg1), 0); return views.get(arg1); } @Override public boolean isViewFromObject(View arg0, Object arg1) { return (arg0 == arg1); } } }
activity_vector.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/vector_layout" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#0099cc"> <android.support.v4.view.ViewPager android:id="@+id/vector_viewpager" android:layout_width="match_parent" android:layout_height="match_parent" /> <LinearLayout android:id="@+id/ll" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_centerHorizontal="true" android:layout_marginBottom="40dp" android:orientation="horizontal"> <ImageView android:layout_width="30dp" android:layout_height="30dp" android:layout_gravity="center_vertical" android:clickable="true" android:padding="12dp" android:src="@drawable/dot" android:visibility="gone" /> <ImageView android:layout_width="30dp" android:layout_height="30dp" android:layout_gravity="center_vertical" android:clickable="true" android:padding="12dp" android:src="@drawable/dot" android:visibility="gone" /> <ImageView android:layout_width="30dp" android:layout_height="30dp" android:layout_gravity="center_vertical" android:clickable="true" android:padding="12dp" android:src="@drawable/dot" android:visibility="gone" /> <ImageView android:layout_width="30dp" android:layout_height="30dp" android:layout_gravity="center_vertical" android:clickable="true" android:padding="12dp" android:src="@drawable/dot" android:visibility="gone" /> <ImageView android:layout_width="30dp" android:layout_height="30dp" android:layout_gravity="center_vertical" android:clickable="true" android:padding="12dp" android:src="@drawable/dot" android:visibility="gone" /> </LinearLayout> <ImageView android:id="@+id/vector_end_button" android:layout_width="130dp" android:layout_height="45dp" android:layout_alignParentBottom="true" android:layout_centerHorizontal="true" android:layout_marginBottom="40dp" android:src="@drawable/start1" android:visibility="invisible" /> </RelativeLayout>
dot.xml
<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_selected="false"> <shape> <solid android:color="@color/colorAccent" /> <corners android:radius="20dp" /> </shape> </item> <item android:state_selected="true"> <shape> <solid android:color="@color/colorPrimaryDark" /> <corners android:radius="20dp" /> </shape> </item> </selector>
2016年9月3日12:40:59
写完之后一看表还不到7点,还可以。走喽,回家。
很讨厌,也很厌恶:工作不好好做,拖拖拉拉,磨磨唧唧。是自己的工作就一定做好。不是自己的工作,想做也去做,但不可强求吧?做工作,都是那种做一会儿,玩一会儿。正常下班下不了,每次都要加班。最讨厌这种人,哥工作做完就走!天天让加班,周末还加班。可是加班干什么?不反对加班,但是反对没有效率的工作!