赞
踩
这是自己学习过程单独做出来的,挺适合新手学习,熟悉最基本的banner,imageview,listview,text等等基础控件,适合初学者,原项目共有五个模块,这个是其中一个模块
提示:以下是本篇文章正文内容,下面案例可供参考
总体思路概述:
如上方效果图所示,我们顶部是使用了一个banner的控件来实现图片的轮播效果,这里我使用的是第三方插件,所以实现的轮播代码相对于简短,下方我提供的项目源码里面就有,下方的的服务入口使用了我们最基础的LinearLayout的布局,在布局里面放了ImageView和TextView控件,这都是我们最基础的控件,也很适合初学者学习,同理,下方的新闻导航栏,也是直接使用TextView控件实现,在下方新闻列表也是最常见的ListView控件,最下方的底部导航栏使用了RadioButton控件和Fragment来实现点击图标变色和切换到不同页面的操作。有需要完整源代码可运行的,可以看下方项目链接,可直接导入运行。
fragment_host1.xml的代码如下(示例):
<?xml version="1.0" encoding="utf-8"?> <LinearLayout 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:orientation="vertical" tools:context=".hostFragment.HostFragment1"> <!-- TODO: Update blank fragment layout --> <com.youth.banner.Banner android:id="@+id/banner1" android:layout_width="match_parent" android:layout_height="200dp" /> <LinearLayout android:layout_width="match_parent" android:layout_height="30dp"> <TextView android:id="@+id/textView" android:layout_width="match_parent" android:layout_height="match_parent" android:text="推荐服务" android:gravity="center_vertical"/> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <LinearLayout android:layout_width="match_parent" android:layout_height="80dp" android:orientation="horizontal"> <LinearLayout android:layout_width="0dp" android:layout_weight="1" android:layout_height="wrap_content" android:orientation="vertical" > <ImageView android:id="@+id/image1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@mipmap/ditie" /> <TextView android:id="@+id/ditie" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="6dp" android:layout_weight="1" android:text="城市地铁" /> </LinearLayout> <LinearLayout android:layout_width="0dp" android:layout_weight="1" android:layout_height="wrap_content" android:orientation="vertical" > <ImageView android:id="@+id/image2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@mipmap/bus"/> <TextView android:id="@+id/bus" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="6dp" android:layout_weight="1" android:text="智慧巴士" /> </LinearLayout> <LinearLayout android:layout_width="0dp" android:layout_weight="1" android:layout_height="wrap_content" android:orientation="vertical" > <ImageView android:id="@+id/image3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@mipmap/menzheng"/> <TextView android:id="@+id/menzheng" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="6dp" android:layout_weight="1" android:text="门诊预约" /> </LinearLayout> <LinearLayout android:layout_width="0dp" android:layout_weight="1" android:layout_height="wrap_content" android:orientation="vertical" > <ImageView android:id="@+id/image4" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@mipmap/live"/> <TextView android:id="@+id/live" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="6dp" android:layout_weight="1" android:text="生活缴费" /> </LinearLayout> <LinearLayout android:layout_width="0dp" android:layout_weight="1" android:layout_height="wra
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。