Walkers闪屏和引导界面

   实战 Walker 之闪屏界面的实现

一、界面效果图




   实现效果: 当用户启动应用程序时,首先出现一闪屏界面,显示 3 秒后,跳转到主界面,这里假设
                               先跳转到登录界面。

    二、 实现过程

1、修改自动生成的 activity_welcome.xml 文件,主要代码如下:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/welcome_bg"
tools:context=".WelcomeActivity" >
</RelativeLayout>

2、修改 AndroidManifest.xml 文件,修改闪屏界面为全屏模式
<activity
android:name="cn.edu.bztc.walkersimulate.WelcomeActivity"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:label="@string/title_activity_welcome" >
</activity>
3、修改 WelcomeActivity,实现停顿 3 秒后跳转
方式 1:利用动画持续时间,动画结束后跳转,主要代码如下:
public class WelcomeActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_welcome);
RelativeLayout layoutWelcome=(RelativeLayout) findViewById(R.id.layoutWelcome);
AlphaAnimation alphaAnimation=new AlphaAnimation(0.1f,1.0f);
alphaAnimation.setDuration(3000);
layoutWelcome.startAnimation(alphaAnimation);
alphaAnimation.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
} 
@Override
public void onAnimationRepeat(Animation animation) {
} 
@Override
public void onAnimationEnd(Animation animation) {
Intent intent=new Intent(WelcomeActivity.this,LoginActivity.class);
startActivity(intent);
}
});
}
}
方式 2:使用 Handler 完成跳转
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
Intent intent=new Intent(WelcomeActivity.this,LoginActivity.class);
startActivity(intent); 
}
},3000);
方式 3:使用多线程完成跳转
new Thread() {
public void run() {
try {
Thread.sleep(3000);
Intent intent = new Intent(WelcomeActivity.this,
LoginActivity.class);
startActivity(intent);
} catch (InterruptedException e) {
e.printStackTrace();
}
};
}.start();

实战 Walker  之引导 界面的实现

一、界面效果图

     

实现效果:通过引导界面,用户能够快速了解应用的主要功能。当滑动到最后一个界面时,点击Go 进入到主界面。

二、 实现过程
1、设计引导界面整体布局,修改自动生成的 activity_guide.xml 文件,在布局文件里首先加入 ViewPager 这个组件,然后加入加入四个 ImageView 组件,主要代码如下:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
<span style="white-space:pre">	</span>xmlns:tools="http://schemas.android.com/tools"
<span style="white-space:pre">	</span>android:layout_width="match_parent"
<span style="white-space:pre">	</span>android:layout_height="match_parent"
<span style="white-space:pre">	</span>tools:context=".GuideActivity" >
<android.support.v4.view.ViewPager
<span style="white-space:pre">	</span>android:id="@+id/vpGuide"
<span style="white-space:pre">	</span>android:layout_width="wrap_content"
<span style="white-space:pre">	</span>android:layout_height="wrap_content"
<span style="white-space:pre">	</span>android:layout_alignParentLeft="true"
<span style="white-space:pre">	</span>android:layout_alignParentTop="true" >
</android.support.v4.view.ViewPager>
<!--底部的四个圆点-->
<LinearLayout
<span style="white-space:pre">	</span>android:layout_width="wrap_content"
<span style="white-space:pre">	</span>android:layout_height="wrap_content"
<span style="white-space:pre">	</span>android:layout_alignParentBottom="true"
<span style="white-space:pre">	</span>android:layout_centerHorizontal="true"
<span style="white-space:pre">	</span>android:layout_marginBottom="40dp" >
<span style="white-space:pre">	</span><ImageView
<span style="white-space:pre">		</span>android:id="@+id/guide_dot1"
<span style="white-space:pre">		</span>android:layout_width="wrap_content"
<span style="white-space:pre">		</span>android:layout_height="wrap_content"
<span style="white-space:pre">		</span>android:background="@drawable/bg_point_selected" />
<span style="white-space:pre">	</span><ImageView
<span style="white-space:pre">		</span>android:id="@+id/guide_dot2"
<span style="white-space:pre">		</span>android:layout_width="wrap_content"
<span style="white-space:pre">		</span>android:layout_height="wrap_content"
<span style="white-space:pre">		</span>android:layout_marginLeft="10dp"
<span style="white-space:pre">		</span>android:background="@drawable/bg_point" />
<span style="white-space:pre">	</span><ImageView
<span style="white-space:pre">		</span>android:id="@+id/guide_dot3"
<span style="white-space:pre">		</span>android:layout_width="wrap_content"
<span style="white-space:pre">		</span>android:layout_height="wrap_content"
<span style="white-space:pre">		</span>android:layout_marginLeft="10dp"
<span style="white-space:pre">		</span>android:background="@drawable/bg_point" />
<span style="white-space:pre">	</span><ImageView
<span style="white-space:pre">		</span>android:id="@+id/guide_dot4"
<span style="white-space:pre">		</span>android:layout_width="wrap_content"
<span style="white-space:pre">		</span>android:layout_height="wrap_content"
<span style="white-space:pre">		</span>android:layout_marginLeft="10dp"
<span style="white-space:pre">		</span>android:background="@drawable/bg_point" />
<span style="white-space:pre">	</span></LinearLayout>
</RelativeLayout>
其中 bg_point_selected.xml 文件如下
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval" >
<solid android:color="#427AB7" />
<size
android:height="8dp"
android:width="8dp" />
</shape>
bg_point.xml 文件如下
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval" >
<!-- 未被选中 -->
<solid android:color="@android:color/black" />
<size
android:height="8dp"
android:width="8dp" />
</shape>
2、定义好 要切换 的布局 文件 view1_of_pager.xml 文件、view2_of_pager.xml 文件、
view3_of_pager.xml 文件、view4_of_pager.xml 文件
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<span style="white-space:pre">	</span>android:layout_width="match_parent"
<span style="white-space:pre">	</span>android:layout_height="match_parent"
<span style="white-space:pre">	</span>android:background="@drawable/guide_1"
<span style="white-space:pre">	</span>android:orientation="vertical" >
</LinearLayout>

view4_of_pager.xml 文件代码如下:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
<span style="white-space:pre">	</span>android:layout_width="match_parent"
<span style="white-space:pre">	</span>android:layout_height="match_parent"
<span style="white-space:pre">	</span>android:background="@drawable/guide_1"
<span style="white-space:pre">	</span>android:orientation="vertical" >
<span style="white-space:pre">	</span><TextView
<span style="white-space:pre">		</span>android:id="@+id/tvGo"
<span style="white-space:pre">		</span>android:layout_width="wrap_content"
<span style="white-space:pre">		</span>android:layout_height="wrap_content"
<span style="white-space:pre">		</span>android:layout_alignParentBottom="true"
<span style="white-space:pre">		</span>android:layout_alignParentRight="true"
<span style="white-space:pre">		</span>android:layout_marginBottom="16dp"
<span style="white-space:pre">		</span>android:layout_marginRight="19dp"
<span style="white-space:pre">		</span>android:background="@drawable/start_select"
<span style="white-space:pre">		</span>android:gravity="center"
<span style="white-space:pre">		</span>android:text="Go"
<span style="white-space:pre">		</span>android:textColor="#ffffff"
<span style="white-space:pre">		</span>android:textSize="30sp" />
</RelativeLayout>
其中 start_select.xml 文件如下
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/start_before"
android:state_pressed="false"/>
<item android:drawable="@drawable/start_after"
android:state_pressed="true"/>
</selector>
start_before.xml 文件如下:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval" >
<solid android:color="#2362A7" />
<size
android:height="80dp"
android:width="80dp" />
</shape>
3、编写 GuideAdapter 类 extends PageAdapter
public class GuideAdapter extends PagerAdapter {
private List<View> views;
public GuideAdapter(List<View> views) {
this.views = views;
}
@Override
public int getCount() {
return views.size();
}
@Override
public boolean isViewFromObject(View view, Object object) {
return view == object;
}
@Override
public Object instantiateItem(ViewGroup container, int position) {
container.addView(views.get(position));
return views.get(position);
}
@Override
public void destroyItem(ViewGroup container, int position, Object object) {
View view = views.get(position);
container.removeView(view);
}
}
4、修改 GuideActivity 类,代码如下:
public class GuideActivity extends Activity {
private List<View> guideViews;
private ViewPager vpGuide;
private int[] guide_dots = { R.id.guide_dot1, R.id.guide_dot2,
<pre name="code" class="java">R.id.guide_dot3, R.id.guide_dot4 };// 4 个导航点
private ImageView[] dots;
private TextView tvGo;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_guide);
initGuideViews();
tvGo=(TextView) findViewById(R.id.tvGo);
initDots();
setListeners();
}
private void initDots() {
dots=new ImageView[4];
for(int i=0;i<dots.length;i++){
dots[i]=(ImageView) findViewById(guide_dots[i]);
}
}
private void setListeners() {
vpGuide.setOnPageChangeListener(new OnPageChangeListener() {
@Override
public void onPageSelected(int position) {
for (int i = 0; i < guide_dots.length; i++) {
if (position == i) {
dots[i].setImageResource(R.drawable.bg_point_selected);
} else {
dots[i].setImageResource(R.drawable.bg_point);
}
}
}
@Override
public void onPageScrolled(int arg0, float arg1, int arg2) {
}
@Override
public void onPageScrollStateChanged(int arg0) {
}
});
tvGo.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
Intent intent=new Intent(GuideActivity.this,LoginActivity.class);
startActivity(intent);
}
});
}
private void initGuideViews() {
vpGuide=(ViewPager) findViewById(R.id.vpGuide);
//准备好切换的 view
guideViews=new ArrayList<View>();
LayoutInflater layoutInflater=LayoutInflater.from(this);
guideViews.add(layoutInflater.inflate(R.layout.view1ofpager, null));
guideViews.add(layoutInflater.inflate(R.layout.view2ofpager, null));
guideViews.add(layoutInflater.inflate(R.layout.view3ofpager, null));
guideViews.add(layoutInflater.inflate(R.layout.view4ofpager, null));
GuideAdapter guideAdapter=new GuideAdapter(guideViews);
vpGuide.setAdapter(guideAdapter);
}
}



 
 



















  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
毕业设计,基于SpringBoot+Vue+MySQL开发的校园二手书交易平台,源码+数据库+毕业论文+视频演示 信息数据从传统到当代,是一直在变革当中,突如其来的互联网让传统的信息管理看到了革命性的曙光,因为传统信息管理从时效性,还是安全性,还是可操作性等各个方面来讲,遇到了互联网时代才发现能补上自古以来的短板,有效的提升管理的效率和业务水平。传统的管理模式,时间越久管理的内容越多,也需要更多的人来对数据进行整理,并且数据的汇总查询方面效率也是极其的低下,并且数据安全方面永远不会保证安全性能。结合数据内容管理的种种缺点,在互联网时代都可以得到有效的补充。结合先进的互联网技术,开发符合需求的软件,让数据内容管理不管是从录入的及时性,查看的及时性还是汇总分析的及时性,都能让正确率达到最高,管理更加的科学和便捷。本次开发的校园二手书交易平台实现了图书信息查询。系统用到了关系型数据库中MySql作为系统的数据库,有效的对数据进行安全的存储,有效的备份,对数据可靠性方面得到了保证。并且程序也具备程序需求的所有功能,使得操作性还是安全性都大大提高,让校园二手书交易平台更能从理念走到现实,确确实实的让人们提升信息处理效率。 关键字:信息管理,时效性,安全性,MySql;Spring Boot
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值