如何在layout中使用tab(横屏底部)

我现在用一个viewflipper切换几个layout
但是问题是我其中一个layout上想显示一个这样的tab在横屏的下方
以用来点击显示相应的内容
不知道怎么实现啊
这个tab又要实现tabActivity类
如何是这样
那样不就变成用viewFlipper实现layout和activity之间的切换了吗?
附件: 您需要登录才可以下载或查看附件。没有帐号?免费加入

<?xml version="1.0" encoding="utf-8"?>
  <TabHost xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/tabhost"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <RelativeLayout
        androidrientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        >
        <TabWidget
            android:id="@android:id/tabs"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            />
        <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent">
            <TextView
                android:id="@+id/textview1"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:text="this is a tab" />
            <TextView
                android:id="@+id/textview2"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:text="this is another tab" />
            <TextView
                android:id="@+id/textview3"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:text="this is a third tab" />
        </FrameLayout>
    </RelativeLayout>
  </TabHost>

TOP

本帖最后由 muyue 于 2010-2-2 17:32 编辑

其实你也可以用一排button来显示;;;


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

<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content" android:id="@+id/mPath_1"
android:padding="5px" android:textSize="18sp" android:textColor="@drawable/white" />

<ListView android:id="@+id/android:list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1.0" />

<LinearLayout style="@android:style/ButtonBar"
android:layout_width="fill_parent" android:layout_height="wrap_content"
androidrientation="horizontal">
<Button android:id="@+id/button_library_1" android:text="@string/menu1"
android:layout_width="0dip" android:layout_height="wrap_content"
android:layout_weight="1" />
<Button android:id="@+id/button_picture_1" android:text="@string/menu2"
android:layout_width="0dip" android:layout_height="wrap_content"
android:layout_weight="1" />
<Button android:id="@+id/button_audio_1" android:text="@string/menu3"
android:layout_width="0dip" android:layout_height="wrap_content"
android:layout_weight="1" />
<Button android:id="@+id/button_notes_1" android:text="@string/menu4"
android:layout_width="0dip" android:layout_height="wrap_content"
android:layout_weight="1" />
<Button android:id="@+id/button_settings_1" android:text="@string/menu5"
android:layout_width="0dip" android:layout_height="wrap_content"
android:layout_weight="1" />
</LinearLayout>
</LinearLayout>

TOP

学习了

TOP

不过 style="@android:style/ButtonBar" 在sdk1.5中没有找到。。。

TOP

谢谢你的回答
我是用button来实现的
keep moving and smiling

TOP

对了我用你所说的button style的方法,能不能去除掉之间的间隙啊,
我试了padding什么的都没有效果啊

这是我的xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
androidrientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout style="@android:style/ButtonBar"
     android:layout_alignParentBottom="true"
  android:layout_width="fill_parent" android:layout_height="wrap_content"
  androidrientation="horizontal">
  <Button android:id="@+id/button_library_1" android:text="111"
   android:layout_width="0dip" android:layout_height="wrap_content"
   android:layout_weight="1"
   android:padding="0dip"/>
  <Button android:id="@+id/button_picture_1" android:text="222"
   android:layout_width="0dip" android:layout_height="wrap_content"
   android:layout_weight="1"
   android:padding="0dip"/>
  <Button android:id="@+id/button_audio_1" android:text="333"
   android:layout_width="0dip" android:layout_height="wrap_content"
   android:layout_weight="1"
   android:padding="0dip"/>
  <Button android:id="@+id/button_notes_1" android:text="444"
   android:layout_width="0dip" android:layout_height="wrap_content"
   android:layout_weight="1"
   android:padding="0dip"/>
  <Button android:id="@+id/button_settings_1" android:text="555"
   android:layout_width="0dip" android:layout_height="wrap_content"
   android:layout_weight="1"
   android:padding="0dip"/>
</LinearLayout>
</RelativeLayout>
附件: 您需要登录才可以下载或查看附件。没有帐号?免费加入
keep moving and smiling

TOP

你可以用ImageButton的方式,因該就感覺不到中間的空了

TOP

谢谢分享

TOP

厉害!
开心了就笑,不开心了就过会儿再笑!

TOP

强啊,学习了,谢谢!
学习是一个不断坚持的过程,只要努力,一切都会有回报!

TOP

好东西,学习了
<LinearLayout style="@android:style/ButtonBar"
     android:layout_alignParentBottom="true"
  android:layout_width="fill_parent" android:layout_height="wrap_content"
  androidrientation="horizontal">
  <Button android:id="@+id/button_library_1" android:text="111"
   android:layout_width="0dip" android:layout_height="wrap_content"
   android:layout_weight="1"
   android:padding="0dip"/>
Just a new learner for android!I will stick it!

TOP

支持!
生命没有绝对精彩,只有更加精彩

TOP

厉害.收藏了.
Android初学者

TOP

我现在用一个viewflipper切换几个layout
但是问题是我其中一个layout上想显示一个这样的tab在横屏的下方
以 ...
brain_first 发表于 2010-2-1 09:38



    http://news.wangmeng.cn/detailNe ... imitation-buttonbar

TOP

强烈推荐 关闭


易联致远靳岩、马万铮:吸引初学者加入Android开发

8月28日,易联致远(旗下运营国内eoeandroid开发社区)CEO靳岩和CTO马万铮编著的新书《Google Android创赢路线与产品开发实践》在西单图书大厦举行签售活动。CB对 ...


查看