首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > Iphone >

【转】android UI进阶之仿iphone的tab成效(二)

2012-12-27 
【转】android UI进阶之仿iphone的tab效果(二)今天把这个仿iphone效果的tab写完,这个例子参考国外rolle3k共

【转】android UI进阶之仿iphone的tab效果(二)

今天把这个仿iphone效果的tab写完,这个例子参考国外rolle3k共享的代码,感谢rolle3k。

上篇博客我们写了一个Itab类,介绍了背景的绘制和简单的一个图的贴图方法。我们继续来完成Itab这个类,同时把他放到MainAcitvity(继承Activity)这个类内部,这样,整个程序只需一个类就可以了。(上篇博客例子运行需要再建一个Activity的子类来作为lanucher)。废话不多说了,看看代码

是不是非常漂亮呢。下面就是xml里面的配置了

?

?> 2 3 <view xmlns:android="http://schemas.android.com/apk/res/android" 4 class="com.notice520.MainActivity$iRelativeLayout" 5 android:orientation="vertical" 6 android:layout_width="fill_parent" 7 android:layout_height="fill_parent" 8 android:background = "#C5CCD4FF" 9 > 10 <LinearLayout 11 android:id = "@+id/TabLayout_One" 12 android:layout_width = "fill_parent" 13 android:layout_height = "fill_parent" 14 android:layout_above = "@+id/Tabs" 15 > 16 <ScrollView android:layout_width="fill_parent" android:layout_height="wrap_content"> 17 <RelativeLayout 18 android:layout_width = "fill_parent" 19 android:layout_height = "fill_parent" 20 android:visibility = "visible" 21 > 22 <TextView 23 android:textColor="@android:color/black" 24 android:textSize="30sp" 25 android:layout_width = "wrap_content" 26 android:layout_height = "wrap_content" 27 android:text = "春节快乐!!" 28 /> 29 </RelativeLayout> 30 </ScrollView> 31 </LinearLayout> 32 33 <LinearLayout 34 android:id = "@+id/TabLayout_Two" 35 android:layout_width = "fill_parent" 36 android:layout_height = "fill_parent" 37 android:layout_above = "@+id/Tabs" 38 > 39 <ScrollView android:layout_width="fill_parent" android:layout_height="wrap_content"> 40 <RelativeLayout 41 android:layout_width = "fill_parent" 42 android:layout_height = "fill_parent" 43 android:visibility = "visible" 44 android:layout_above = "@+id/Tabs" 45 > 46 <Button 47 android:layout_width = "wrap_content" 48 android:layout_height = "wrap_content" 49 android:text = "祝大家事业有成!" 50 android:textSize = "30sp" 51 /> 52 </RelativeLayout> 53 </ScrollView> 54 </LinearLayout> 55 <LinearLayout 56 android:id = "@+id/TabLayout_Three" 57 android:layout_width = "fill_parent" 58 android:layout_height = "fill_parent" 59 android:layout_above = "@+id/Tabs" 60 > 61 <ScrollView android:layout_width="fill_parent" android:layout_height="wrap_content"> 62 <RelativeLayout 63 android:layout_width = "fill_parent" 64 android:layout_height = "fill_parent" 65 android:visibility = "visible" 66 android:layout_above = "@+id/Tabs" 67 > 68 <ImageView 69 70 android:layout_width = "fill_parent" 71 android:layout_height = "fill_parent" 72 android:src="@drawable/newq" 73 /> 74 </RelativeLayout> 75 </ScrollView> 76 </LinearLayout> 77 <LinearLayout 78 android:id = "@+id/TabLayout_Four" 79 android:layout_width = "fill_parent" 80 android:layout_height = "fill_parent" 81 android:layout_above = "@+id/Tabs" 82 > 83 <ScrollView android:layout_width="fill_parent" android:layout_height="wrap_content"> 84 <RelativeLayout 85 android:id = "@+id/TabLayout_Four" 86 android:layout_width = "fill_parent" 87 android:layout_height = "fill_parent" 88 android:visibility = "visible" 89 android:layout_above = "@+id/Tabs" 90 > 91 <TextView 92 android:textColor="@android:color/black" 93 android:layout_width = "wrap_content" 94 android:layout_height = "wrap_content" 95 android:text = "很简单,是么" 96 /> 97 </RelativeLayout> 98 </ScrollView> 99 </LinearLayout> 100 <view101 class="com.notice520.MainActivity$iTab"102 android:id="@+id/Tabs"103 android:layout_width = "fill_parent"104 android:layout_height = "49px"105 android:layout_alignParentBottom = "true"106 /> 107 </view>108

来看看最终的效果吧

【转】android UI进阶之仿iphone的tab成效(二)

是不是还不错呢? 希望大家喜欢,有问题可以留言交流。

<script type="text/javascript"></script>

热点排行