`
xindrace
  • 浏览: 95735 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

TabHost点击按钮布局改变

 
阅读更多

main.xml

<?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" >

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical"
        android:paddingTop="5.0dip" >

        <TabWidget
            android:id="@android:id/tabs"
            android:layout_width="fill_parent"
            android:layout_height="50.0dip"
            android:background="@drawable/tab_frame_indicator"
            android:gravity="center" />

        <ImageView
            android:layout_width="fill_parent"
            android:layout_height="5.0dip"
            android:background="@drawable/tab_frame_separate" />

        <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent" />
    </LinearLayout>

</TabHost>

tab_frame_indicator.xml

 

<?xml version="1.0" encoding="UTF-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@drawable/tab_frame_focus" android:state_pressed="true"/>
    <item android:drawable="@drawable/tab_frame_focus" android:state_focused="true" android:state_window_focused="true"/>
    <item android:drawable="@drawable/tab_frame_focus" android:state_selected="true"/>
    <item android:drawable="@drawable/tab_frame_background" />
</selector>

 

fl_tabhost_indicator_pitchon.xml

<?xml version="1.0" encoding="UTF-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" 
    android:background="@drawable/tab_frame_indicator">

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:orientation="horizontal" >

        <ImageView
            android:id="@+id/tab_image"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />

        <TextView
            android:id="@+id/tab_label"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_toRightOf="@id/tab_image"
            android:textAppearance="?android:textAppearanceSmall"
            android:textSize="15sp"
            android:textStyle="bold"
            android:textColor="@android:color/white"
            android:visibility="gone" />
    </LinearLayout>

</RelativeLayout>

 

效果图:

图片不会上传呀!!!

 <!--StartFragment -->

  • 大小: 11.1 KB
0
1
分享到:
评论

相关推荐

    android使用了自定义button自定义tabHost切换页面Demo

    1. **初始化TabHost**:首先在布局文件中定义TabHost,并使用`TabHost.setup()`方法进行初始化。 2. **添加Tab**:使用`TabHost.addTab()`方法添加Tab,传入TabSpec对象,该对象包含了Tab的标签文本、图标以及对应...

    TabHost使用(自定义按钮菜单)

    每个按钮点击时,可以通过改变内容区域显示相应的页面。 ```xml &lt;!-- 在布局文件中创建自定义按钮菜单 --&gt; android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation=...

    andorid中TabHost的使用

    通过TabHost,开发者可以创建一个多页面的用户界面,让用户通过点击不同的标签来浏览不同的内容区域。 二、TabHost的基本结构 1. TabWidget:显示标签的组件,每个标签对应一个按钮。 2. FrameLayout:用来承载被...

    android自定义TabHost

    如果需要在运行时改变背景颜色,可以在用户触发某个事件(如点击按钮)时,使用`ColorDrawable`动态设置TabHost的背景颜色,例如: ```java TabHost tabHost = (TabHost) findViewById(R.id.tabhost); tabHost....

    tab切换之tabhost模式

    Android默认的Tab样式可能无法满足所有需求,可以通过自定义布局文件来改变Tab的外观,包括文字颜色、大小、图标等。 **7. 动态添加和移除Tab** 在某些场景下,可能需要根据用户操作动态添加或移除Tab。可以通过`...

    可以横向拖动的tabHost

    这个“可以横向拖动的TabHost”项目提供了一种创新的交互方式,让用户可以通过水平滑动来切换不同的Tab,而非传统的点击按钮。下面我们将深入探讨TabHost的基本概念、可拖动的实现原理以及如何在实际开发中应用这一...

    radiobutton 实现tabhost的功能

    在Android应用开发中,`RadioButton`和`TabHost`是两个重要的组件,分别用于实现单选按钮和标签页切换的功能。本项目通过`RadioButton`来模拟`TabHost`的效果,适用于像微博那样需要多标签页浏览的应用场景。下面将...

    android 利用radiobutton实现tabhost效果

    4. **样式定制**:为了达到类似TabHost的效果,我们可以修改RadioButton的样式,例如,使用自定义的背景图片,改变文字颜色和大小等。这可以在主题(Theme)中定义,或者直接在XML布局中设置。 5. **交互反馈**:...

    TabHost加载Activity及自定义底部导航栏的实现

    - 可以添加平滑过渡的动画效果,比如使用TransitionDrawable在按钮被点击时改变颜色。 总结,TabHost加载Activity和自定义底部导航栏是Android开发中常见的界面设计模式。通过合理的配置和事件处理,可以构建出...

    tabhost+radiogroup

    在Android开发中,`TabHost` 和 `RadioGroup` 是两个重要的组件,它们分别用于创建传统的标签页式界面和实现单选按钮组的功能。在标题"tabhost+radiogroup"中,提到的是一个不使用标准`TabWidget`,而是利用`...

    用radiogroup和gridview模拟tabhost

    `RadioGroup`是Android中的一个布局容器,用于管理一组单选按钮(RadioButton)。它的主要功能是确保同一时间只有一个单选按钮被选中。而`GridView`则是一个可滚动的二维网格视图,可以用来展示一系列的项目,每个...

    tabhost效果

    这样的示例可能展示了如何在每个标签页内添加按钮菜单,并处理相应的点击事件。 总结来说,`TabHost`是Android早期实现多视图导航的重要组件,它通过`TabSpec`来定义和管理标签。虽然现在有更现代的替代方案,如`...

    Android之底部導航欄--RadioGroup、TabHost、TabActivity

    `RadioGroup`是Android提供的一个布局容器,用于管理一组单选按钮(RadioButton)。在RadioGroup中,用户只能选择一个RadioButton,当一个被选中时,其他所有RadioButton都会自动取消选中。在底部导航栏的场景中,...

    FragmentTabHost实现中间按钮凸出效果(Android Studio项目)

    此外,为了使效果更加动态,我们还可以添加触摸反馈,比如点击时改变颜色或动画效果。可以监听Tab的点击事件,然后相应地更新自定义TabIndicator的状态。 在整个项目中,"Demo_FragmentTabhost"可能包含了实现这个...

    安卓FragmentTab选项卡相关-仿微信TabHost.rar

    这个"安卓FragmentTab选项卡相关-仿微信TabHost.rar"压缩包文件很可能是为了展示如何使用`FragmentTabHost`来创建一个与微信类似的界面布局。下面将详细讲解`FragmentTabHost`及其相关知识点。 `FragmentTabHost`是...

    多个button互相切换view<实例一>

    例如,如果有多个界面需要使用相同的按钮布局,我们可以将这些按钮的布局定义在一个单独的XML文件中,然后在需要的地方使用`include`标签引入。这样不仅减少了代码量,也使得布局结构更加清晰。 在实例中,开发者...

    多个button互相切换view<实例二3D切换>

    1. **布局设计**:创建包含多个按钮的布局文件,每个按钮对应一个视图。可以使用`&lt;include&gt;`标签将重复的布局部分抽取出来,提高代码的可复用性和可维护性。 2. **监听事件**:为每个按钮添加OnClickListener监听器...

    Fragment碎片

    4. **处理按钮点击事件**:在Activity中,为按钮设置点击监听器,当按钮被点击时,调用FragmentManager的相关方法来添加或替换Fragment。 5. **使用FragmentManager**:使用FragmentManager的`beginTransaction()`...

    推选Android中使用选项卡、列表视图完成“休闲时分”应用的核心代码详解PPT资料.pptx

    在布局XML文件中,TabHost的id应设置为`@android:id/tabhost`,TabWidget的id设置为`@android:id/tabs`。 接下来,我们探讨如何实现列表视图。ListView是一个可滚动的视图,可以显示多个项目行。在“休闲时分”应用...

Global site tag (gtag.js) - Google Analytics