当前位置:首页 » 安卓系统 » android引导页图片

android引导页图片

发布时间: 2023-03-13 02:16:00

㈠ android studio引导页怎么做

引导页的话,一般使用框架就可以了,也可以叫美工制作,然后使用一些视频播放的技巧。

㈡ android开屏页的实现--图片和视屏

图片引导页结合咕咚,视屏开屏页引进蚂蜂窝的案例。

一、如何实现android开屏页,滑动小圆点带动图片切换。

大概所有的app都是有这个简单的需求。第一次进入app时,显示引导图再是闪屏图,之后就只是闪屏咯。实现逻辑就是对是否是第一次进入该app进行判断,这里可以采取SharedPreferences存储方式进行记录下,我们可以写一个utils用来存储第一次进入app的状态。

每次在闪屏界面onCreate()判断一下。

引导页的实现--自定一个view

具体实现请查看demo

demo地址

请教一个问题,怎么在文章里添加动态图啊?!?!

㈢ android studio怎么设置引导页

基本上现在所有的应用都会有一个欢迎界面,在欢迎界面对应用做一个整体的介绍,然后在跳入到主界面,这次要说的这个引导页就是带翻页的引导页。效果如下所示



概要实现

主要分为两部分功能,一个是翻页效果,一个是页面位置指示器。为了实现翻页效果我采用系统自带的ViewPager对象来实现;页面指示器则通过一个LinearLayout在其中放置相应个数的图片,然后根据页面的滑动动态修改各个图片的资源。布局文件如下所示



复制代码
1 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
2 xmlns:tools="http://schemas.android.com/tools"
3 android:layout_width="match_parent"
4 android:layout_height="match_parent"
5 tools:context=".MainActivity" >
6
7 <android.support.v4.view.ViewPager
8 xmlns:android="http://schemas.android.com/apk/res/android"
9 android:id="@+id/welcome_pager"
10 android:layout_width="match_parent"
11 android:layout_height="match_parent" />
12
13 <!-- 图片位置指示器 -->
14 <LinearLayout
15 android:id="@+id/director"
16 android:layout_width="match_parent"
17 android:layout_height="wrap_content"
18 android:gravity="center_horizontal"
19 android:orientation="horizontal"
20 android:layout_marginBottom="15dip"
21 android:layout_alignParentBottom="true"
22 >
23
24 <ImageView
25 android:layout_width="wrap_content"
26 android:layout_height="wrap_content"
27 android:background="@drawable/pageindicator_on" />
28
29 <ImageView
30 android:layout_width="wrap_content"
31 android:layout_height="wrap_content"
32 android:background="@drawable/pageindicator_off" />
33
34 <ImageView
35 android:layout_width="wrap_content"
36 android:layout_height="wrap_content"
37 android:background="@drawable/pageindicator_off" />
38
39 <ImageView
40 android:layout_width="wrap_content"
41 android:layout_height="wrap_content"
42 android:background="@drawable/pageindicator_off" />
43 </LinearLayout>
44
45 </RelativeLayout>
复制代码

ViewPager

先来看下官方解释:Layout manager that allows the user to flip left and right through pages of data.意思是说,Viewpage是一个允许用户在多个页面数据之间通过左滑或者右滑的方式切换页面数据的布局管理器。

主要功能点有两部分,数据适配器Adapter,和事件监听器OnPageChangeListener。数据适配器用来管理这个ViewPager对象的显示内容,而OnPageChangeListener用来处理当页面切换的时候的行为动作,我修改页面指示器就是通过这个事件来完成的。

适配器



复制代码
1 class pagerAdapter extends FragmentPagerAdapter{
2
3 public pagerAdapter(FragmentManager fm) {
4 super(fm);
5 }
6
7 @Override
8 public Fragment getItem(int arg0) {
9 //得到要显示的对象并初始化图片
10 WelcomeFragment fm = new WelcomeFragment();
11 fm.setImg(imgs.get(arg0));
12
13 return fm;
14 }
15
16 @Override
17 public int getCount() {
18 return imgs.size();
19 }
20
21 }
复制代码
上面这段就是ViewPager要用的适配器了,其中imgs是一个id数组,存放了要在欢迎界面展示的图片的id,WelcomeFragment是一个Fragment类,用来展示页面内容,这两个代码会在完整代码中体现。两个方法需要实现,getCout,用来表示有多少个页面;getItem,用来获取指定位置的Pager对象。

imgs数组定义及实现:

复制代码
1 List<Integer> imgs = null;
2 //初始化欢迎界面图片数组
3 imgs = new ArrayList<Integer>();
4 imgs.add(R.drawable.help1);
5 imgs.add(R.drawable.help2);
6 imgs.add(R.drawable.help3);
7 imgs.add(R.drawable.help4);
复制代码
WelcomeFragment类定义



复制代码
1 public class WelcomeFragment extends Fragment {
2
3 View view = null;
4 int imgId ;
5 @Override
6 public View onCreateView(LayoutInflater inflater, ViewGroup container,
7 Bundle savedInstanceState) {
8 view = inflater.inflate(R.layout.welcome_fragment, null);
9
10 ImageView fragmentVw = (ImageView) view.findViewById(R.id.welcome_Img);
11 fragmentVw.setBackgroundResource(imgId);
12 return view;
13 }
14
15 /**
16 * 为该Fragment设置显示图片
17 * */
18 public void setImg(int imgID){
19
20 imgId = imgID;
21 }
22 }
复制代码
WelcomeFragment布局文件

复制代码
1 <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
2 android:layout_width="match_parent"
3 android:layout_height="match_parent" >
4
5 <ImageView
6 android:id="@+id/welcome_Img"
7 android:contentDescription="welcome"
8 android:layout_width="match_parent"
9 android:layout_height="match_parent" />
10
11 </FrameLayout>
复制代码


事件监听器OnPageChangeListener

这个监听器用来监听页面切换事件,实现这个接口用来处理页面切换时,页面指示器跟着改变状态。实现代码如下

复制代码
1 /**
2 * 页面切换的事件监听器
3 * */
4 class pageChangeListener implements OnPageChangeListener{
5
6 /**
7 * 当某一个页面被选中的时候触发
8 * */
9 @Override
10 public void onPageSelected(int arg0) {
11 int count = directorLayout.getChildCount();
12 /**
13 * 指示器自对象顺序和页面显示顺序一样的设置为on,其余的设置为off
14 * */
15 for(int i=0;i<count;i++){
16 ImageView iv = (ImageView) directorLayout.getChildAt(i);
17 if(i == arg0){
18 iv.setBackgroundResource(R.drawable.pageindicator_on);
19 }else{
20 iv.setBackgroundResource(R.drawable.pageindicator_off);
21 }
22 }
23 }
24
25 @Override
26 public void onPageScrolled(int arg0, float arg1, int arg2) {
27 // TODO Auto-generated method stub
28 }
29
30 @Override
31 public void onPageScrollStateChanged(int arg0) {
32 // TODO Auto-generated method stub
33 }
34 }

㈣ android怎么从引导页进入主页

1 import android.app.Activity;
2 import android.content.Intent;
3 import android.content.SharedPreferences;
4 import android.content.SharedPreferences.Editor;
5 import android.os.Bundle;
6 import android.os.Handler;
7
8 /** 欢迎界面 */
9 public class WelcomeAct extends Activity {
10
11 private boolean isFirstIn = false;
12 private static final int TIME = 2000;
13 private static final int GO_HOME = 1000;
14 private static final int GO_GUIDE = 1001;
15
16 private Handler mHandler = new Handler() {
17 public void handleMessage(android.os.Message msg) {
18 switch (msg.what) {
19 // 跳入主界面
20 case GO_HOME:
21 goHome();
22 break;
23 // 跳入引导页
24 case GO_GUIDE:
25 goGuide();
26 break;
27 }
28 };
29 };
30
31 @Override
32 protected void onCreate(Bundle savedInstanceState) {
33 super.onCreate(savedInstanceState);
34 setContentView(R.layout.welcome);
35 init();
36 }
37
38 private void init() {
39 SharedPreferences perPreferences = getSharedPreferences("jike",
40 MODE_PRIVATE);
41 isFirstIn = perPreferences.getBoolean("isFirstIn", true);
42 if (!isFirstIn) {
43 mHandler.sendEmptyMessageDelayed(GO_HOME, TIME);
44 } else {
45 mHandler.sendEmptyMessageDelayed(GO_GUIDE, TIME);
46 Editor editor = perPreferences.edit();
47 editor.putBoolean("isFirstIn", false);
48 editor.commit();
49 }
50 }
51
52 private void goHome() {
53 Intent i = new Intent(WelcomeAct.this, MainActivity.class);
54 startActivity(i);
55 finish();
56 }
57
58 private void goGuide() {
59 Intent i = new Intent(WelcomeAct.this, Guide.class);
60 startActivity(i);
61 finish();
62 }
63
64 }

1 import java.util.ArrayList;
2 import java.util.List;
3 import android.app.Activity;
4 import android.content.Intent;
5 import android.os.Bundle;
6 import android.support.v4.view.ViewPager;
7 import android.support.v4.view.ViewPager.OnPageChangeListener;
8 import android.view.LayoutInflater;
9 import android.view.View;
10 import android.view.View.OnClickListener;
11 import android.widget.Button;
12 import android.widget.ImageView;
13
14 /** 引导页 */
15 public class Guide extends Activity implements OnPageChangeListener {
16
17 private ViewPager vp;
18 private ViewPagerAdapter vpAdapter;
19 private List<View> views;
20 private ImageView[] dots;
21 private int[] ids = { R.id.iv1, R.id.iv2, R.id.iv3 };
22 private Button start_btn;
23
24 @Override
25 protected void onCreate(Bundle savedInstanceState) {
26 super.onCreate(savedInstanceState);
27 setContentView(R.layout.guide);
28 initViews();
29 initDots();
30 }
31
32 private void initViews() {
33 LayoutInflater inflater = LayoutInflater.from(this);
34
35 views = new ArrayList<View>();
36 views.add(inflater.inflate(R.layout.one, null));
37 views.add(inflater.inflate(R.layout.two, null));
38 views.add(inflater.inflate(R.layout.three, null));
39
40 vpAdapter = new ViewPagerAdapter(views, this);
41 vp = (ViewPager) findViewById(R.id.viewpager);
42 vp.setAdapter(vpAdapter);
43 // 下标从0开始,所以第三个页面是get(2)。
44 start_btn = (Button) views.get(2).findViewById(R.id.start_btn);
45 start_btn.setOnClickListener(new OnClickListener() {
46 @Override
47 public void onClick(View arg0) {
48 Intent i = new Intent(Guide.this, MainActivity.class);
49 startActivity(i);
50 finish();
51 }
52 });
53 vp.setOnPageChangeListener(this);
54 }
55
56 /** 循环设置点 */
57 private void initDots() {
58 dots = new ImageView[views.size()];
59 for (int i = 0; i < views.size(); i++) {
60 dots[i] = (ImageView) findViewById(ids[i]);
61 }
62 }
63
64 @Override /** 滑动状态改变的时候 */
65 public void onPageScrollStateChanged(int arg0) {
66 // TODO Auto-generated method stub
67 }
68
69 @Override /** 当页面被滑动时候调用 */
70 public void onPageScrolled(int arg0, float arg1, int arg2) {
71 // TODO Auto-generated method stub
72 }
73
74 @Override /** 当前新的页面被选中时调用 */
75 public void onPageSelected(int arg0) {
76 for (int i = 0; i < ids.length; i++) {
77 if (arg0 == i) {
78 // 亮点
79 dots[i].setImageResource(R.drawable.login_point_selected);
80 } else {
81 // 暗点
82 dots[i].setImageResource(R.drawable.login_point);
83 }
84 }
85 }
86
87 }
1 <?xml version="1.0" encoding="utf-8"?>
2 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
3 android:layout_width="match_parent"
4 android:layout_height="match_parent" >
5
6 <android.support.v4.view.ViewPager
7 android:id="@+id/viewpager"
8 android:layout_width="fill_parent"
9 android:layout_height="fill_parent"
10 android:background="#00000000" >
11 </android.support.v4.view.ViewPager>
12
13 <!-- 底部三个点 -->
14 <LinearLayout
15 android:id="@+id/ll"
16 android:layout_width="fill_parent"
17 android:layout_height="wrap_content"
18 android:layout_alignParentBottom="true"
19 android:gravity="center_horizontal"
20 android:orientation="horizontal" >
21 <!-- 选中点 -->
22 <ImageView
23 android:id="@+id/iv1"
24 android:layout_width="wrap_content"
25 android:layout_height="wrap_content"
26 android:src="@drawable/login_point_selected" />
27 <!-- 未选中点 -->
28 <ImageView
29 android:id="@+id/iv2"
30 android:layout_width="wrap_content"
31 android:layout_height="wrap_content"
32 android:src="@drawable/login_point" />
33 <!-- 未选中点 -->
34 <ImageView
35 android:id="@+id/iv3"
36 android:layout_width="wrap_content"
37 android:layout_height="wrap_content"
38 android:src="@drawable/login_point" />
39 </LinearLayout>
40
41 </RelativeLayout>

㈤ android 安卓 类似ONE卡片页(包含图片文字等)怎么实现

Android5.0中向我们介绍了一个全新的控件–CardView,从本质上看,可以将CardView看做是FrameLayout在自身之上添加了圆角和阴影效果。请注意:CardView被包装为一种布局,并且经常在ListView和RecyclerView的Item布局中,作为一种容器使用。

下面例子来源于android学习手册, android学习手册包含9个章节,108个例子,源码文档随便看,例子都是可交互,可运行,源码采用android studio目录结构,高亮显示代码,文档都采用文档结构图显示,可以快速定位。360手机助手中下载,排在第四个。

CardView应该被使用在显示层次性的内容时;在显示列表或网格时更应该被选择,因为这些边缘可以使得用户更容易去区分这些内容。

使用CardView

首先,假设你的布局如同下面的形式:

<FrameLayout xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content"> <!-- Main Content View --> <RelativeLayout> ... </RelativeLayout> </FrameLayout>

为了使用上面的布局方式来创建一个卡片,首先你需要导入支持的依赖库(android-support-v7-cardview的jar包)在你的build.gradle文件中。

dependencies { ... compile 'com.android.support:cardview-v7:21.0.2' }

现在将FrameLayout替换为CardView,

<android.support.v7.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto" xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content"> <!-- Main Content View --> <RelativeLayout> ... </RelativeLayout> </android.support.v7.widget.CardView>

就是这样!使用依赖库能够保证你的程序稳定的兼容之前的版本;尽管在AndroidL和之前的Android版本中对其处理方式有所不同。

热点内容
app什么情况下找不到服务器 发布:2025-05-12 15:46:25 浏览:714
php跳过if 发布:2025-05-12 15:34:29 浏览:467
不定时算法 发布:2025-05-12 15:30:16 浏览:131
c语言延时1ms程序 发布:2025-05-12 15:01:30 浏览:166
动物园灵长类动物配置什么植物 发布:2025-05-12 14:49:59 浏览:736
wifi密码设置什么好 发布:2025-05-12 14:49:17 浏览:148
三位数乘两位数速算法 发布:2025-05-12 13:05:48 浏览:399
暴风影音缓存在哪里 发布:2025-05-12 12:42:03 浏览:544
access数据库exe 发布:2025-05-12 12:39:04 浏览:632
五开的配置是什么 发布:2025-05-12 12:36:37 浏览:366