安卓模拟新浪微博客户端

android开发模拟新浪微博客户端
开始接触学习android已经有一段时间了,这是老师让我们做的一个模拟新浪客户端页面的项目。
项目效果图如下:

  首先新建名为HomeActivity.java的Activity作为用户首页,然后在res/layout目录下新建名为home.xml的Layout,具体代码如下:`
<?xml version="1.0" encoding="utf-8"?>  
    <LinearLayout  
    xmlns:android="http://schemas.android.com/apk/res/android"  
    android:id="@+id/layout"  
    android:orientation="vertical"  
    android:layout_width="fill_parent"  
    android:layout_height="fill_parent">  

    <RelativeLayout  
    android:layout_width="fill_parent"  
    android:layout_height="wrap_content"  
    android:layout_margin="3px">  
    <ImageView  
    android:layout_width="wrap_content"  
    android:layout_height="wrap_content"  
    android:src="@drawable/logo_ss">  
    </ImageView>  
    <TextView  
    android:id="@+id/showName"  
    android:layout_width="wrap_content"  
    android:layout_height="wrap_content"  
    android:layout_centerInParent="true"  
    android:textColor="#343434"  
    android:textSize="15px">  
    </TextView>  
    <ImageButton  
    android:id="@+id/writeBtn"  
    android:layout_width="wrap_content"  
    android:layout_height="wrap_content"  
    android:layout_toLeftOf="@+id/refreshBtn"  
    android:background="@drawable/btn_write_selector">  
    </ImageButton>  
    <ImageButton  
    android:id="@+id/refreshBtn"  
    android:layout_width="wrap_content"  
    android:layout_height="wrap_content"  
    android:layout_alignParentRight="true"  
    android:layout_marginLeft="12px"  
    android:background="@drawable/btn_refresh_selector">  
    </ImageButton>  
    </RelativeLayout>  

    <LinearLayout  
    android:layout_width="fill_parent"  
    android:layout_height="wrap_content"  
    android:background="@drawable/hr">  
    </LinearLayout>  

    <RelativeLayout  
    android:layout_width="fill_parent"  
    android:layout_height="fill_parent">  

    <ListView  
    android:id="@+id/Msglist"  
    android:layout_width="fill_parent"  
    android:layout_height="match_parent"  
    android:divider="@drawable/divider"  
    android:dividerHeight="2px"  
    android:layout_margin="0px"  
    android:background="#BBFFFFFF"  
    android:cacheColorHint="#00000000"  
    android:layout_above="@+id/toolbarLayout"  
    android:fastScrollEnabled="true"   
    android:focusable="true">  
    </ListView>  

    <LinearLayout  
    android:id="@+id/loadingLayout"  
    android:layout_width="wrap_content"  
    android:layout_height="wrap_content"  
    android:orientation="vertical"  
    android:visibility="invisible"  
    android:layout_centerInParent="true">  
    <ProgressBar  
    android:id="@+id/loading"  
    android:layout_width="31px"  
    android:layout_height="31px"  
    android:layout_gravity="center"  
    style="@style/progressStyle">  
    </ProgressBar>  
    <TextView  
    android:layout_width="wrap_content"  
    android:layout_height="wrap_content"  
    android:text="正在载入"  
    android:textSize="12px"  
    android:textColor="#9c9c9c"  
    android:layout_gravity="center"  
    android:layout_below="@+id/loading">  
    </TextView>  
    </LinearLayout>  


    <LinearLayout  
    android:id="@+id/toolbarLayout"  
    android:layout_width="fill_parent"  
    android:layout_height="44dip"  
    android:layout_alignParentBottom="true">  
    </LinearLayout>  
    </RelativeLayout>  
    </LinearLayout>  

[java] view plaincopy

    <?xml version="1.0" encoding="utf-8"?>  
    <LinearLayout  
    xmlns:android="http://schemas.android.com/apk/res/android"  
    android:id="@+id/layout"  
    android:orientation="vertical"  
    android:layout_width="fill_parent"  
    android:layout_height="fill_parent">  

    <RelativeLayout  
    android:layout_width="fill_parent"  
    android:layout_height="wrap_content"  
    android:layout_margin="3px">  
    <ImageView  
    android:layout_width="wrap_content"  
    android:layout_height="wrap_content"  
    android:src="@drawable/logo_ss">  
    </ImageView>  
    <TextView  
    android:id="@+id/showName"  
    android:layout_width="wrap_content"  
    android:layout_height="wrap_content"  
    android:layout_centerInParent="true"  
    android:textColor="#343434"  
    android:textSize="15px">  
    </TextView>  
    <ImageButton  
    android:id="@+id/writeBtn"  
    android:layout_width="wrap_content"  
    android:layout_height="wrap_content"  
    android:layout_toLeftOf="@+id/refreshBtn"  
    android:background="@drawable/btn_write_selector">  
    </ImageButton>  
    <ImageButton  
    android:id="@+id/refreshBtn"  
    android:layout_width="wrap_content"  
    android:layout_height="wrap_content"  
    android:layout_alignParentRight="true"  
    android:layout_marginLeft="12px"  
    android:background="@drawable/btn_refresh_selector">  
    </ImageButton>  
    </RelativeLayout>  

    <LinearLayout  
    android:layout_width="fill_parent"  
    android:layout_height="wrap_content"  
    android:background="@drawable/hr">  
    </LinearLayout>  

    <RelativeLayout  
    android:layout_width="fill_parent"  
    android:layout_height="fill_parent">  

    <ListView  
    android:id="@+id/Msglist"  
    android:layout_width="fill_parent"  
    android:layout_height="match_parent"  
    android:divider="@drawable/divider"  
    android:dividerHeight="2px"  
    android:layout_margin="0px"  
    android:background="#BBFFFFFF"  
    android:cacheColorHint="#00000000"  
    android:layout_above="@+id/toolbarLayout"  
    android:fastScrollEnabled="true"   
    android:focusable="true">  
    </ListView>  

    <LinearLayout  
    android:id="@+id/loadingLayout"  
    android:layout_width="wrap_content"  
    android:layout_height="wrap_content"  
    android:orientation="vertical"  
    android:visibility="invisible"  
    android:layout_centerInParent="true">  
    <ProgressBar  
    android:id="@+id/loading"  
    android:layout_width="31px"  
    android:layout_height="31px"  
    android:layout_gravity="center"  
    style="@style/progressStyle">  
    </ProgressBar>  
    <TextView  
    android:layout_width="wrap_content"  
    android:layout_height="wrap_content"  
    android:text="正在载入"  
    android:textSize="12px"  
    android:textColor="#9c9c9c"  
    android:layout_gravity="center"  
    android:layout_below="@+id/loading">  
    </TextView>  
    </LinearLayout>  


    <LinearLayout  
    android:id="@+id/toolbarLayout"  
    android:layout_width="fill_parent"  
    android:layout_height="44dip"  
    android:layout_alignParentBottom="true">  
    </LinearLayout>  
    </RelativeLayout>  
    </LinearLayout>     

  这个布局首先是一个竖直的根LinearLayout,在这个根LinearLayout里面分别是两个RelativeLayout, 第一个RelativeLayout 用来显示页面的工具条,第二个RelativeLayout用来显示列表以及底部的功能栏,特别主要在这第二个RelativeLayout中有一个id为loadingLayout的LinearLayout是用来显示数据载入中的动画,它的android:visibility属性为invisible(也可以设置成gone,区别:invisible这个View在ViewGroupt中仍保留它的位置,不重新layout
gone>不可见,但这个View在ViewGroupt中不保留位置,重新layout,那后面的view就会取代他的位置。 ),也就是一开始不显示的意思,接下来看看


    <?xml version="1.0" encoding="UTF-8"?>  
    <resources>  
    <mce:style name="progressStyle" width="38" height="38" parent="@android:style/Widget.ProgressBar.Small"><!--  
    <item name="android:indeterminateDrawable">@anim/loading</item>  
    --></mce:style><style name="progressStyle" width="38" height="38" parent="@android:style/Widget.ProgressBar.Small" mce_bogus="1"><item name="android:indeterminateDrawable">@anim/loading</item></style>  
    </resources>  

[java] view plaincopy

    <?xml version="1.0" encoding="UTF-8"?>  
    <resources>  
    <mce:style name="progressStyle" width="38" height="38" parent="@android:style/Widget.ProgressBar.Small"><!--  
    <item name="android:indeterminateDrawable">@anim/loading</item>  
    --></mce:style><style name="progressStyle" width="38" height="38" parent="@android:style/Widget.ProgressBar.Small" mce_bogus="1"><item name="android:indeterminateDrawable">@anim/loading</item></style>  
    </resources>  
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值