转载  转载请注明出处:http://blog.csdn.net/lmj623565791/article/details/23513993

本来准备下载个CSDN的客户端放手机上,没事可以浏览浏览资讯,下载了官方的之后,发现并不能很好的使用。恰好搜到一个大神自己写的csdn的app,下载安装了一下,感觉很不错,也很流畅,基本满足了我们 日常浏览的需求。

app效果图:

我会在博客中完整的介绍这个项目的制作,第一篇当然是整个项目的整体结构了。

效果图:

1、头部的布局文件,这个很简单:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.zhy.csdndemo"
android:versionCode="1"
android:versionName="1.0" > <uses-sdk
android:minSdkVersion="13"
android:targetSdkVersion="17" /> <application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.zhy.csdndemo.MainActivity"
android:label="@string/app_name"
android:theme="@style/MyTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application> </manifest>

就显示一个图标和标题。
2、主布局文件:

<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:background="#eee"
android:orientation="vertical" > <include layout="@layout/main_head" /> <com.viewpagerindicator.TabPageIndicator
android:id="@+id/id_indicator"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@color/transparentblue" >
</com.viewpagerindicator.TabPageIndicator> <android.support.v4.view.ViewPager
android:id="@+id/id_pager"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1" /> </LinearLayout>

一个TabPageIndicator和一个ViewPager。
3、主Activity

TabAdapter.java

MainFragment.java

package com.zhy.csdndemo;

import android.annotation.SuppressLint;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView; @SuppressLint("ValidFragment")
public class MainFragment extends Fragment
{ private int newsType = 0; public MainFragment(int newsType)
{
this.newsType = newsType;
} @Override
public void onActivityCreated(Bundle savedInstanceState)
{
super.onActivityCreated(savedInstanceState);
} @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
View view = inflater.inflate(R.layout.tab_item_fragment_main, null);
TextView tip = (TextView) view.findViewById(R.id.id_tip);
tip.setText(TabAdapter.TITLES[newsType]);
return view;
} }

4、在styles.xml中自定义Theme

<style name="MyTheme" parent="AppBaseTheme">
<item name="vpiTabPageIndicatorStyle">@style/MyWidget.TabPageIndicator</item>
<item name="android:windowBackground">@drawable/init_pic</item>
<item name="android:windowNoTitle">true</item>
<item name="android:animationDuration">5000</item>
<item name="android:windowContentOverlay">@null</item>
</style> <style name="MyWidget.TabPageIndicator" parent="Widget">
<item name="android:gravity">center</item>
<item name="android:background">@drawable/vpi__tab_indicator</item>
<item name="android:paddingLeft">22dip</item>
<item name="android:paddingRight">22dip</item>
<item name="android:paddingTop">8dp</item>
<item name="android:paddingBottom">8dp</item>
<item name="android:textAppearance">@style/MyTextAppearance.TabPageIndicator</item>
<item name="android:textSize">16sp</item>
<item name="android:maxLines">1</item>
</style> <style name="MyTextAppearance.TabPageIndicator" parent="Widget">
<item name="android:textStyle">bold</item>
<item name="android:textColor">@color/black</item>
</style>

在AndroidManifest中注册使用:

总体还是很简单的,但是效果很不错啊,现在不是流行Fragment么~好了 ,如果这篇文章对你有帮助,赞一个~

Android 使用Fragment,ViewPagerIndicator 制作csdn app主要框架的更多相关文章

  1. 客户端上显示csdn上的各类别下的的文章列表 (制作csdn app 三)

    转载请标明出处:http://blog.csdn.net/lmj623565791/article/details/23597229 今天将在Android 使用Fragment,ViewPagerI ...

  2. 抓取csdn上的各类别的文章 (制作csdn app 二)

    转载请表明出处:http://blog.csdn.net/lmj623565791/article/details/23532797 这篇博客接着上一篇(Android 使用Fragment,View ...

  3. 实现app上对csdn的文章列表上拉刷新下拉加载以及加入缓存文章列表的功能 (制作csdn app 四)

    转载请标明出处:http://blog.csdn.net/lmj623565791/article/details/23698511 今天继续对我们的csdn客户端未完成的功能进行实现,本篇博客接着客 ...

  4. 实现app上对csdn的文章查看,以及文章中图片的保存 (制作csdn app 完结篇)

    转载请标明出处:http://blog.csdn.net/lmj623565791/article/details/24022165 今天给大家带来CSDN的完结篇,即增加文章的查看和文章中图片的保存 ...

  5. Android中Fragment和ViewPager那点事儿(仿微信APP)

    在之前的博文<Android中使用ViewPager实现屏幕页面切换和引导页效果实现>和<Android中Fragment的两种创建方式>以及<Android中Fragm ...

  6. Android ViewPager Fragment使用懒加载提升性能

     Android ViewPager Fragment使用懒加载提升性能 Fragment在如今的Android开发中越来越普遍,但是当ViewPager结合Fragment时候,由于Androi ...

  7. [转]Android:Activity+Fragment及它们之间的数据交换(一)

    2014-05-18         来源:Android:Activity+Fragment及它们之间的数据交换(一)   简介: 为什么要用Fragment?使用Fragment可以在一个Acti ...

  8. Android中Fragment与Activity之间的交互(两种实现方式)

    (未给Fragment的布局设置BackGound) 之前关于Android中Fragment的概念以及创建方式,我专门写了一篇博文<Android中Fragment的两种创建方式>,就如 ...

  9. Android使用Fragment来实现ViewPager的功能(解决切换Fragment状态不保存)以及各个Fragment之间的通信

    以下内容为原创,转载请注明:http://www.cnblogs.com/tiantianbyconan/p/3364728.html 我前两天写过一篇博客<Android使用Fragment来 ...

随机推荐

  1. 题目1005:Graduate Admission

    题目1005:Graduate Admission 时间限制:1 秒 内存限制:32 兆 特殊判题:否 题目描述: It is said that in 2011, there are about 1 ...

  2. Java将Unix时间戳转换成指定格式日期

    public String TimeStamp2Date(String timestampString, String formats){     Long timestamp = Long.pars ...

  3. 如何实现从Android第三方平台推送微信公众号

    最近心血来潮,想要尝试写写有关实现Android平台第三方应用软件去跳转到微信平台的代码.我只是先暂时写写我的思路,如后期实现,便将主要代码附上. 微信公众平台官方宣布微信沟通接口正式上线,用户可以在 ...

  4. Comparing cards

    For built-in types, there are conditional operators (<, >, ==, etc.) that compare values and d ...

  5. OSGI.NET 插件启动方法

    在使用OSGI.NET框架来开发插件过程中,有时为了测试一个插件,或运行一个插件,需要启动主个插件,如果没有主窗口程序,那么该 如何启动一个插件,而不是再开发一个主窗口程序(那样是不是太麻烦,仅仅是为 ...

  6. USACO Section 2.2 循环数 Runaround Numbers

    OJ:http://www.luogu.org/problem/show?pid=1467 #include<iostream> #include<vector> #inclu ...

  7. Exceeded maximum number of retries. Exceeded max scheduling attempts 3 for instance 7d90eb80-29e2-4238-b658-ade407ff9456. Last exception: [u'Traceback (most recent call last):\n', u' File "/usr/lib/py

    Exceeded maximum number of retries. Exceeded max scheduling attempts 3 for instance 7d90eb80-29e2-42 ...

  8. java SimpleDateFormat

    心碎了.

  9. HTTP Status 500 - javax.servlet.ServletException

    运行某个jsp页面时提示 type Exception report message javax.servlet.ServletException: java.lang.NoClassDefFound ...

  10. web.config中sessionState节点的配置方案

    web.config中sessionState节点的配置方案 web.config关于sessionState节点的配置方案,sessionState有五种模式:Custom,off,inProc,S ...