【0092】【项目实战】-【谷歌电子市场】-【04】【分类模块开发】【添加首页轮播条】【应用详情页顶部开发】【应用详情页-安全模块】【应用详情页-安全模块动画】
1.分类模块开发
1.1 效果及思路

1.2 网络数据及获取


【分类信息的javaBean的书写】将游戏和信息放在了一起,增加了标记isTiltle标记是否为标题还是分类的信息;

【网络数据的请求】
[标题数据的获取]首先判断是否具有标题的数据,然后再获取标题;



【获取jsonArray的数据】非标题


【循环遍历的内容】

【源码】/GooglePlay74/src/com/itheima/googleplay74/http/protocol/CategoryProtocol.java
1 package com.itheima.googleplay74.http.protocol; 2 3 import java.util.ArrayList; 4 5 import org.json.JSONArray; 6 import org.json.JSONException; 7 import org.json.JSONObject; 8 9 import com.itheima.googleplay74.domain.CategoryInfo; 10 11 /** 12 * 分类模块请求网络 13 * 14 * @author Kevin 15 * @date 2015-11-1 16 */ 17 public class CategoryProtocol extends BaseProtocol<ArrayList<CategoryInfo>> { 18 19 @Override 20 public String getKey() { 21 return "category"; 22 } 23 24 @Override 25 public String getParams() { 26 return ""; 27 } 28 29 @Override 30 public ArrayList<CategoryInfo> parseData(String result) { 31 try { 32 JSONArray ja = new JSONArray(result); 33 34 ArrayList<CategoryInfo> list = new ArrayList<CategoryInfo>(); 35 for (int i = 0; i < ja.length(); i++) {// 遍历大分类, 2次 36 JSONObject jo = ja.getJSONObject(i); 37 38 // 初始化标题对象 39 if (jo.has("title")) {// 判断是否有title这个字段 40 CategoryInfo titleInfo = new CategoryInfo(); 41 titleInfo.title = jo.getString("title"); 42 titleInfo.isTitle = true; 43 list.add(titleInfo); 44 } 45 46 // 初始化分类对象 47 if (jo.has("infos")) { 48 JSONArray ja1 = jo.getJSONArray("infos"); 49 50 for (int j = 0; j < ja1.length(); j++) {// 遍历小分类 51 JSONObject jo1 = ja1.getJSONObject(j); 52 CategoryInfo info = new CategoryInfo(); 53 info.name1 = jo1.getString("name1"); 54 info.name2 = jo1.getString("name2"); 55 info.name3 = jo1.getString("name3"); 56 info.url1 = jo1.getString("url1"); 57 info.url2 = jo1.getString("url2"); 58 info.url3 = jo1.getString("url3"); 59 info.isTitle = false; 60 61 list.add(info); 62 } 63 } 64 } 65 66 return list; 67 68 } catch (JSONException e) { 69 e.printStackTrace(); 70 } 71 return null; 72 } 73 74 }
1.3 fragment中加载更多的禁用
【框架的搭建】


【禁用加载更多】因为分类的模块不需要加载更多,因此需要禁用加载更多的功能

[调用关系]



1.4 fragment中布局数量的增加
【布局数量的添加】重写父类的方法,增加listView的一种类型;现在是三种类型:标题+普通布局+加载更多;
虽然加载更多已经隐藏,只是用户看不到,程序的当中还是存在的;

【listView增加一种布局类型】
[父类]增加位置的参数;


[修改]

1.5 Title布局Holder的添加
【问题】原来的Holder只能添加一种布局,现在需要标题和普通布局两种布局;


【增加position参数】最终目的是为了判断是否是标题的布局;


【新建TitleHolder】


【 标题Holder的添加】

1.6 普通布局的Hodler的添加
【单个item的布局】

【图片中间的白边】本身图片自带的;

【图标的选中具有选择器的效果】


【布局源码】/GooglePlay74/res/layout/list_item_category.xml
1 <?xml version="1.0" encoding="utf-8"?> 2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 3 android:layout_width="match_parent" 4 android:layout_height="wrap_content" 5 android:orientation="vertical" > 6 7 <LinearLayout 8 android:layout_width="match_parent" 9 android:layout_height="match_parent" 10 android:layout_margin="5dp" 11 android:orientation="horizontal" > 12 13 <LinearLayout 14 android:id="@+id/ll_grid1" 15 android:layout_width="0dp" 16 android:layout_height="match_parent" 17 android:layout_weight="1" 18 android:background="@drawable/grid_item_bg_selector" 19 android:gravity="center" 20 android:orientation="vertical" 21 android:padding="5dp" > 22 23 <ImageView 24 android:id="@+id/iv_icon1" 25 android:layout_width="60dp" 26 android:layout_height="60dp" 27 android:src="@drawable/ic_default" /> 28 29 <TextView 30 android:id="@+id/tv_name1" 31 android:layout_width="wrap_content" 32 android:layout_height="wrap_content" 33 android:text="休闲" 34 android:textColor="#000" 35 android:textSize="16sp" /> 36 </LinearLayout> 37 38 <LinearLayout 39 android:id="@+id/ll_grid2" 40 android:layout_width="0dp" 41 android:layout_height="match_parent" 42 android:layout_weight="1" 43 android:background="@drawable/grid_item_bg_selector" 44 android:gravity="center" 45 android:orientation="vertical" 46 android:padding="5dp" > 47 48 <ImageView 49 android:id="@+id/iv_icon2" 50 android:layout_width="60dp" 51 android:layout_height="60dp" 52 android:src="@drawable/ic_default" /> 53 54 <TextView 55 android:id="@+id/tv_name2" 56 android:layout_width="wrap_content" 57 android:layout_height="wrap_content" 58 android:text="休闲" 59 android:textColor="#000" 60 android:textSize="16sp" /> 61 </LinearLayout> 62 63 <LinearLayout 64 android:id="@+id/ll_grid3" 65 android:layout_width="0dp" 66 android:layout_height="match_parent" 67 android:layout_weight="1" 68 android:background="@drawable/grid_item_bg_selector" 69 android:gravity="center" 70 android:orientation="vertical" 71 android:padding="5dp" > 72 73 <ImageView 74 android:id="@+id/iv_icon3" 75 android:layout_width="60dp" 76 android:layout_height="60dp" 77 android:src="@drawable/ic_default" /> 78 79 <TextView 80 android:id="@+id/tv_name3" 81 android:layout_width="wrap_content" 82 android:layout_height="wrap_content" 83 android:text="休闲" 84 android:textColor="#000" 85 android:textSize="16sp" /> 86 </LinearLayout> 87 </LinearLayout> 88 89 </LinearLayout>
【源码】/GooglePlay74/src/com/itheima/googleplay74/ui/holder/CategoryHolder.java
1 package com.itheima.googleplay74.ui.holder; 2 3 import android.view.View; 4 import android.view.View.OnClickListener; 5 import android.widget.ImageView; 6 import android.widget.LinearLayout; 7 import android.widget.TextView; 8 import android.widget.Toast; 9 10 import com.itheima.googleplay74.R; 11 import com.itheima.googleplay74.domain.CategoryInfo; 12 import com.itheima.googleplay74.http.HttpHelper; 13 import com.itheima.googleplay74.utils.BitmapHelper; 14 import com.itheima.googleplay74.utils.UIUtils; 15 import com.lidroid.xutils.BitmapUtils; 16 17 public class CategoryHolder extends BaseHolder<CategoryInfo> implements 18 OnClickListener { 19 20 private TextView tvName1, tvName2, tvName3; 21 private ImageView ivIcon1, ivIcon2, ivIcon3; 22 private LinearLayout llGrid1, llGrid2, llGrid3; 23 24 private BitmapUtils mBitmapUtils; 25 26 @Override 27 public View initView() { 28 View view = UIUtils.inflate(R.layout.list_item_category); 29 30 tvName1 = (TextView) view.findViewById(R.id.tv_name1); 31 tvName2 = (TextView) view.findViewById(R.id.tv_name2); 32 tvName3 = (TextView) view.findViewById(R.id.tv_name3); 33 34 ivIcon1 = (ImageView) view.findViewById(R.id.iv_icon1); 35 ivIcon2 = (ImageView) view.findViewById(R.id.iv_icon2); 36 ivIcon3 = (ImageView) view.findViewById(R.id.iv_icon3); 37 38 llGrid1 = (LinearLayout) view.findViewById(R.id.ll_grid1); 39 llGrid2 = (LinearLayout) view.findViewById(R.id.ll_grid2); 40 llGrid3 = (LinearLayout) view.findViewById(R.id.ll_grid3); 41 42 llGrid1.setOnClickListener(this); 43 llGrid2.setOnClickListener(this); 44 llGrid3.setOnClickListener(this); 45 46 mBitmapUtils = BitmapHelper.getBitmapUtils(); 47 48 return view; 49 } 50 51 @Override 52 public void refreshView(CategoryInfo data) { 53 54 tvName1.setText(data.name1); 55 tvName2.setText(data.name2); 56 tvName3.setText(data.name3); 57 58 mBitmapUtils.display(ivIcon1, HttpHelper.URL + "image?name=" 59 + data.url1); 60 mBitmapUtils.display(ivIcon2, HttpHelper.URL + "image?name=" 61 + data.url2); 62 mBitmapUtils.display(ivIcon3, HttpHelper.URL + "image?name=" 63 + data.url3); 64 65 } 66 67 @Override 68 public void onClick(View v) { 69 CategoryInfo info = getData(); 70 71 switch (v.getId()) { 72 case R.id.ll_grid1: 73 Toast.makeText(UIUtils.getContext(), info.name1, Toast.LENGTH_SHORT) 74 .show(); 75 break; 76 case R.id.ll_grid2: 77 Toast.makeText(UIUtils.getContext(), info.name2, Toast.LENGTH_SHORT) 78 .show(); 79 break; 80 case R.id.ll_grid3: 81 Toast.makeText(UIUtils.getContext(), info.name3, Toast.LENGTH_SHORT) 82 .show(); 83 break; 84 85 default: 86 break; 87 } 88 } 89 90 }

【BUG】点击时候整个item会被点击;

【添加单个图标的点击事件】直接实现OnClickListener即可,子类View会直接取listView中的item的点击事件;



【测试】单个图标可以响应了;

2.添加首页轮播条
2.1 效果及思路
【效果分析】
【1】指示器中的效果是添加了一个空心的圆环,是一张图片;
【2】首页轮播条作为了listView上面添加的头布局,可以上拉推进;

2.2 HomeFragment中添加头布局
【数据来源】轮播条的数据已经解析出来了;




2.3 布局的完成
【说明】
【1】使用纯代码实现布局,因为在sdk开发的jar中无法添加布局文件,一些布局文件,因此需要纯代码实现布局和动画的效果;
【2】可以使用智慧北京单独当中的效果,在这里使用的方式与之前的不同;
【布局完成】写了两个布局,设置参数需要使用的控件的父类的参数;

2.4 数据的添加



【解析数据的返回】

【数据的设置】


【BUG】



【测试1】viewPage可以运行,但是存在的上下的边框;

【修改】将图片进行拉伸,填满父控件;

【测试3】效果可以手动滑动;

2.5 完成连续左右滑动
【设置滑动的最大值】一直不停的滑动,可以滑动60年;


【设置默认的滑动界面】


2.6 完成自动滑动
【说明】
【1】在start()启动,首先移动滑动之前的消息,以免影响切换回来之后的首页的判断;
【2】在run()中增加item的计数,然后postDelayed发消息,形成循环,3s中一个页面的切换;



2.7 添加图片指示器
【说明】添加线性布局;

【添加指示器上的图片】指示器上的图片需要在加载数据之后才知道需要加载指示器的图片的数量;



【添加选中指示】默认第一个选中,并且设置了各个指示器之间的间距;


【指示器跟随图片的滚动而变化】





3.应用详情页顶部开发
3.1 效果及思路
【说明】需要跳转到一个新的Activity中;

3.2 框架的搭建
【说明】继承与BaseActivity,使用LoadingPage对象,书写自己的对应的方法;


【设置view给Activity】之前是将xml布局文件设置给activity,现在直接将View设置给Activity;

【item点击之后页面的跳转】

【测试】跳转之后跳转到了加载中的页面效果;


3.3 请求网络加载数据

【需要加载的网络数据】




3.4 加载网络数据
【javaBean的补充】在AppInfo的文件中补充该字段,没有赋值的时候都是为null,因此不会影响首页使用该javaBean;

【网络数据的加载】每次调用的时候显示的Activity的内容不一致,因此需要通过传递参数进行判断;

[服务器中使用包名进行区分]同样在不同的页面跳转也需要使用不同的参数进行区分;然后通过包名找到对应的不同的json文件解析;

【地址的拼接】

【网络数据的解析】解析json;

【源码】/GooglePlay74/src/com/itheima/googleplay74/http/protocol/HomeDetailProtocol.java
1 package com.itheima.googleplay74.http.protocol; 2 3 import java.util.ArrayList; 4 5 import org.json.JSONArray; 6 import org.json.JSONException; 7 import org.json.JSONObject; 8 9 import com.itheima.googleplay74.domain.AppInfo; 10 import com.itheima.googleplay74.domain.AppInfo.SafeInfo; 11 12 /* 13 * 首页详情页网络访问 14 */ 15 public class HomeDetailProtocol extends BaseProtocol<AppInfo> { 16 17 public String packageName; 18 19 public HomeDetailProtocol(String packageName) { 20 this.packageName = packageName; 21 } 22 23 @Override 24 public String getKey() { 25 return "detail"; 26 } 27 28 @Override 29 public String getParams() { 30 return "&packageName=" + packageName; 31 } 32 33 // 补充字段, 供应用详情页使用 34 public String author; 35 public String date; 36 public String downloadNum; 37 public String version; 38 public ArrayList<SafeInfo> safe; 39 public ArrayList<String> screen; 40 41 @Override 42 public AppInfo parseData(String result) { 43 try { 44 JSONObject jo = new JSONObject(result); 45 46 AppInfo info = new AppInfo(); 47 info.des = jo.getString("des"); 48 info.downloadUrl = jo.getString("downloadUrl"); 49 info.iconUrl = jo.getString("iconUrl"); 50 info.id = jo.getString("id"); 51 info.name = jo.getString("name"); 52 info.packageName = jo.getString("packageName"); 53 info.size = jo.getLong("size"); 54 info.stars = (float) jo.getDouble("stars"); 55 56 info.author = jo.getString("author"); 57 info.date = jo.getString("date"); 58 info.downloadNum = jo.getString("downloadNum"); 59 info.version = jo.getString("version"); 60 61 JSONArray ja = jo.getJSONArray("safe"); 62 63 // 解析安全信息 64 ArrayList<SafeInfo> safe = new ArrayList<AppInfo.SafeInfo>(); 65 for (int i = 0; i < ja.length(); i++) { 66 JSONObject jo1 = ja.getJSONObject(i); 67 68 SafeInfo safeInfo = new SafeInfo(); 69 safeInfo.safeDes = jo1.getString("safeDes"); 70 safeInfo.safeDesUrl = jo1.getString("safeDesUrl"); 71 safeInfo.safeUrl = jo1.getString("safeUrl"); 72 73 safe.add(safeInfo); 74 } 75 76 info.safe = safe; 77 78 // 解析截图信息 79 JSONArray ja1 = jo.getJSONArray("screen"); 80 ArrayList<String> screen = new ArrayList<String>(); 81 for (int i = 0; i < ja1.length(); i++) { 82 String pic = ja1.getString(i); 83 screen.add(pic); 84 } 85 86 info.screen = screen; 87 88 return info; 89 90 } catch (JSONException e) { 91 e.printStackTrace(); 92 } 93 94 return null; 95 } 96 97 }
3.5 应用详情页-数据的加载及状态的返回

【包名参数的传递】
[传递包名]

[获取包名]

【数据请求之后返回数据请求的状态】

3.6 加载成功之后的页面的布局
【分析】整体使用xml搭建框架,然后分为四部分,都是用帧布局切换内部的内容;

【整体框架的一部分】


【使用holder封装上面的布局】

[布局源码]/GooglePlay74/res/layout/layout_detail_appinfo.xml
1 <?xml version="1.0" encoding="utf-8"?> 2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 3 android:layout_width="match_parent" 4 android:layout_height="wrap_content" 5 android:orientation="vertical" 6 android:padding="3dp" > 7 8 <RelativeLayout 9 android:layout_width="match_parent" 10 android:layout_height="wrap_content" 11 android:layout_marginBottom="3dp" > 12 13 <ImageView 14 android:id="@+id/iv_icon" 15 android:layout_width="48dp" 16 android:layout_height="48dp" 17 android:layout_margin="5dp" 18 android:src="@drawable/ic_default" /> 19 20 <TextView 21 android:id="@+id/tv_name" 22 android:layout_width="wrap_content" 23 android:layout_height="wrap_content" 24 android:layout_marginTop="5dp" 25 android:layout_toRightOf="@id/iv_icon" 26 android:singleLine="true" 27 android:text="京东" 28 android:textColor="#000" 29 android:textSize="18sp" /> 30 31 <RatingBar 32 android:id="@+id/rb_star" 33 android:layout_width="wrap_content" 34 android:layout_height="16dp" 35 android:layout_below="@id/tv_name" 36 android:layout_marginTop="5dp" 37 android:layout_toRightOf="@id/iv_icon" 38 android:isIndicator="true" 39 android:progressDrawable="@drawable/custom_ratingbar" 40 android:rating="5" /> 41 </RelativeLayout> 42 43 <LinearLayout 44 android:layout_width="match_parent" 45 android:layout_height="wrap_content" 46 android:orientation="horizontal" 47 android:paddingLeft="5dp" 48 android:paddingRight="5dp" > 49 50 <TextView 51 android:id="@+id/tv_download_num" 52 android:layout_width="wrap_content" 53 android:layout_height="wrap_content" 54 android:layout_weight="1" 55 android:text="下载量:100万+" 56 android:textColor="#9e9e9e" 57 android:textSize="14sp" /> 58 59 <TextView 60 android:id="@+id/tv_version" 61 android:layout_width="wrap_content" 62 android:layout_height="wrap_content" 63 android:layout_weight="1" 64 android:text="版本:1.0" 65 android:textColor="#9e9e9e" 66 android:textSize="14sp" /> 67 </LinearLayout> 68 69 <LinearLayout 70 android:layout_width="match_parent" 71 android:layout_height="wrap_content" 72 android:orientation="horizontal" 73 android:paddingLeft="5dp" 74 android:paddingRight="5dp" > 75 76 <TextView 77 android:id="@+id/tv_date" 78 android:layout_width="wrap_content" 79 android:layout_height="wrap_content" 80 android:layout_weight="1" 81 android:text="2015-08-06" 82 android:textColor="#9e9e9e" 83 android:textSize="14sp" /> 84 85 <TextView 86 android:id="@+id/tv_size" 87 android:layout_width="wrap_content" 88 android:layout_height="wrap_content" 89 android:layout_weight="1" 90 android:text="3.1MB" 91 android:textColor="#9e9e9e" 92 android:textSize="14sp" /> 93 </LinearLayout> 94 95 </LinearLayout>

【Hodler的源码】/GooglePlay74/src/com/itheima/googleplay74/ui/holder/DetailAppInfoHolder.java
1 package com.itheima.googleplay74.ui.holder; 2 3 import android.text.format.Formatter; 4 import android.view.View; 5 import android.widget.ImageView; 6 import android.widget.RatingBar; 7 import android.widget.TextView; 8 9 import com.itheima.googleplay74.R; 10 import com.itheima.googleplay74.domain.AppInfo; 11 import com.itheima.googleplay74.http.HttpHelper; 12 import com.itheima.googleplay74.utils.BitmapHelper; 13 import com.itheima.googleplay74.utils.UIUtils; 14 import com.lidroid.xutils.BitmapUtils; 15 16 /** 17 * 详情页-应用信息 18 * 19 * @author Kevin 20 * @date 2015-11-1 21 */ 22 public class DetailAppInfoHolder extends BaseHolder<AppInfo> { 23 24 private ImageView ivIcon; 25 private TextView tvName; 26 private TextView tvDownloadNum; 27 private TextView tvVersion; 28 private TextView tvDate; 29 private TextView tvSize; 30 private RatingBar rbStar; 31 private BitmapUtils mBitmapUtils; 32 33 @Override 34 public View initView() { 35 View view = UIUtils.inflate(R.layout.layout_detail_appinfo); 36 37 ivIcon = (ImageView) view.findViewById(R.id.iv_icon); 38 tvName = (TextView) view.findViewById(R.id.tv_name); 39 tvDownloadNum = (TextView) view.findViewById(R.id.tv_download_num); 40 tvVersion = (TextView) view.findViewById(R.id.tv_version); 41 tvDate = (TextView) view.findViewById(R.id.tv_date); 42 tvSize = (TextView) view.findViewById(R.id.tv_size); 43 rbStar = (RatingBar) view.findViewById(R.id.rb_star); 44 45 mBitmapUtils = BitmapHelper.getBitmapUtils(); 46 47 return view; 48 } 49 50 @Override 51 public void refreshView(AppInfo data) { 52 mBitmapUtils.display(ivIcon, HttpHelper.URL + "image?name=" 53 + data.iconUrl); 54 tvName.setText(data.name); 55 tvDownloadNum.setText("下载量:" + data.downloadNum); 56 tvVersion.setText("版本号:" + data.version); 57 tvDate.setText(data.date); 58 tvSize.setText(Formatter.formatFileSize(UIUtils.getContext(), data.size)); 59 rbStar.setRating(data.stars); 60 } 61 62 }
【动态添加数据】将首页的应用点击详情放到了HomeDetailActivity中了,减轻了负担;贯穿主线的就是应用的包名;
动态的帧布局中添加解析到的json中的详情内容;

【测试】点击选择不同的按钮就会跳转到Activity中显示不同的应用详情内容,动态加载;

4. 应用详情页-安全模块
4.1【效果分析】
【说明】需要考虑到最多的按钮显示是有多少个,不需要的话可以隐藏掉;


4.2【源码】布局文件源码
1 <?xml version="1.0" encoding="utf-8"?> 2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 3 android:layout_width="match_parent" 4 android:layout_height="wrap_content" 5 android:orientation="vertical" > 6 7 <RelativeLayout 8 android:id="@+id/rl_des_root" 9 android:layout_width="match_parent" 10 android:layout_height="wrap_content" > 11 12 <ImageView 13 android:id="@+id/iv_safe1" 14 android:layout_width="wrap_content" 15 android:layout_height="wrap_content" 16 android:layout_margin="3dp" /> 17 18 <ImageView 19 android:id="@+id/iv_safe2" 20 android:layout_width="wrap_content" 21 android:layout_height="wrap_content" 22 android:layout_margin="3dp" 23 android:layout_toRightOf="@id/iv_safe1" /> 24 25 <ImageView 26 android:id="@+id/iv_safe3" 27 android:layout_width="wrap_content" 28 android:layout_height="wrap_content" 29 android:layout_margin="3dp" 30 android:layout_toRightOf="@id/iv_safe2" /> 31 32 <ImageView 33 android:id="@+id/iv_safe4" 34 android:layout_width="wrap_content" 35 android:layout_height="wrap_content" 36 android:layout_margin="3dp" 37 android:layout_toRightOf="@id/iv_safe3" /> 38 39 <ImageView 40 android:id="@+id/iv_arrow" 41 android:layout_width="wrap_content" 42 android:layout_height="wrap_content" 43 android:layout_alignParentRight="true" 44 android:layout_centerVertical="true" 45 android:layout_margin="5dp" 46 android:src="@drawable/arrow_down" /> 47 </RelativeLayout> 48 49 <LinearLayout 50 android:id="@+id/ll_des_root" 51 android:layout_width="match_parent" 52 android:layout_height="wrap_content" 53 android:orientation="vertical" 54 android:padding="5dp" > 55 56 <LinearLayout 57 android:id="@+id/ll_des1" 58 android:layout_width="match_parent" 59 android:layout_height="wrap_content" 60 android:gravity="center_vertical" 61 android:orientation="horizontal" > 62 63 <ImageView 64 android:id="@+id/iv_des1" 65 android:layout_width="20dp" 66 android:layout_height="20dp" /> 67 68 <TextView 69 android:id="@+id/tv_des1" 70 android:layout_width="wrap_content" 71 android:layout_height="wrap_content" 72 android:singleLine="true" 73 android:textColor="#9e9e9e" 74 android:textSize="14sp" /> 75 </LinearLayout> 76 77 <LinearLayout 78 android:id="@+id/ll_des2" 79 android:layout_width="match_parent" 80 android:layout_height="wrap_content" 81 android:gravity="center_vertical" 82 android:orientation="horizontal" > 83 84 <ImageView 85 android:id="@+id/iv_des2" 86 android:layout_width="20dp" 87 android:layout_height="20dp" /> 88 89 <TextView 90 android:id="@+id/tv_des2" 91 android:layout_width="wrap_content" 92 android:layout_height="wrap_content" 93 android:singleLine="true" 94 android:textColor="#9e9e9e" 95 android:textSize="14sp" /> 96 </LinearLayout> 97 98 <LinearLayout 99 android:id="@+id/ll_des3" 100 android:layout_width="match_parent" 101 android:layout_height="wrap_content" 102 android:gravity="center_vertical" 103 android:orientation="horizontal" > 104 105 <ImageView 106 android:id="@+id/iv_des3" 107 android:layout_width="20dp" 108 android:layout_height="20dp" /> 109 110 <TextView 111 android:id="@+id/tv_des3" 112 android:layout_width="wrap_content" 113 android:layout_height="wrap_content" 114 android:singleLine="true" 115 android:textColor="#9e9e9e" 116 android:textSize="14sp" /> 117 </LinearLayout> 118 119 <LinearLayout 120 android:id="@+id/ll_des4" 121 android:layout_width="match_parent" 122 android:layout_height="wrap_content" 123 android:gravity="center_vertical" 124 android:orientation="horizontal" > 125 126 <ImageView 127 android:id="@+id/iv_des4" 128 android:layout_width="20dp" 129 android:layout_height="20dp" /> 130 131 <TextView 132 android:id="@+id/tv_des4" 133 android:layout_width="wrap_content" 134 android:layout_height="wrap_content" 135 android:singleLine="true" 136 android:textColor="#9e9e9e" 137 android:textSize="14sp" /> 138 </LinearLayout> 139 </LinearLayout> 140 141 </LinearLayout>
4.3【数据的设置更新】使用数组获取布局中的图片


【设置帧布局】以便可以动态的更改帧布局上的内容;

【初始化安全描述模块】

【减小帧布局的上下距离】

【测试】可以显示安全模块的内容;


5.应用详情页-安全模块动画
5.1 效果及思路
【说明】在点击安全模块的任何一个区域,都会将内容展开或者是收起;

5.2 属性动画


【属性动画】能够通过安全模块的高度的值的变化,不断的改变该模块的内容的展开和收起;

【取到该安全模块的高度】





【通过参数将该模块的高度参数设置为0】

【动画的处理】


【箭头变化的效果】上下箭头是两张图片,不停的进行切换即可;需要设置动画的监听;






浙公网安备 33010602011771号