程序设计实践第三周
上周主要任务
上周主要任务是对整个软件的布局设计进行了整合,修改。整合过程中因为环境的配置不同导致了部分错误,根据日志文件以及参考网上信息对开发环境进行了更新配置,修改了sdk版本。解决了问题。整个程序的界面已经大体有了雏形。程序的主界面采用了ToolBar+SlidingTabLayout的设计,引入侧滑栏。
//ToolBar静态布局
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimaryDark" />
//侧滑栏静态布局
<com.example.lenovo.learning.SlidingTabLayout
android:id="@+id/sliding_tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimaryDark"
android:paddingLeft="20dp"
android:paddingRight="20dp" />
//ListView静态布局
<ListView
android:id="@+id/navdrawer"
android:layout_width="@dimen/navdrawer_width"
android:layout_height="match_parent"
android:layout_gravity="start"
android:layout_marginTop="?attr/actionBarSize"
android:background="?attr/colorPrimaryDark"
android:choiceMode="singleChoice"
android:divider="@android:color/white"
android:dividerHeight="1dp"
android:drawSelectorOnTop="false"></ListView>
本周主要任务
本周主要任务是对整个程序的UI设计进行了一定的修改。登陆页面加入了通过手机号验证重置密码的选项,同时登录界面参考了其他软件进行了重新设计,添加了图标信息,更加符合人们的审美习惯。整个程序的大体布局框架基本形成,但是对于广告栏的设计还尚未加入。下一步主要打算加入广告栏的功能,主要学习ViewPage及其相关的使用。主要就是把图片存入List容器里面然后根据position来展示不同的图片。
//广告栏XML静态布局
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >
<!-- ViewPager是一个控件 -->
<android.support.v4.view.ViewPager
android:id="@+id/adv_pager"
android:layout_width="fill_parent"
android:layout_height="130dp" >
</android.support.v4.view.ViewPager>
<LinearLayout
android:id="@+id/viewGroup"
android:layout_below="@id/adv_pager"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="-25px"
android:gravity="right"
android:orientation="horizontal" >
</LinearLayout>
//基本java代码
List<View> advPics = new ArrayList<View>();
ImageView img1 = new ImageView(this);
img1.setBackgroundResource(R.mipmap.ic_launcher);
advPics.add(img1);
//不同的小页面
switch(position){
case 0:
rootView = inflater.inflate(R.layout.page0, container, false);
break;
case 1:
/*****************/
break;
default:
/*****************/
}