设为首页 加入收藏

TOP

android FragmentTabhost导航分页(二)
2019-08-31 00:05:18 】 浏览:60
Tags:android FragmentTabhost 导航
dp" android:layout_height="0dp" android:layout_weight="0" /> </android.support.v4.app.FragmentTabHost> </LinearLayout>

tab_item_view.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:orientation="vertical">
    <ImageView
        android:id="@+id/imageview"
        android:layout_width="40dp"
        android:layout_height="40dp"
        android:layout_margin="3dp"
        />
    <TextView
        android:id="@+id/textview"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="1dp"
        android:textSize="12sp"
        android:layout_marginBottom="2dp"/>
</LinearLayout>

main_bottom_image_selector图片选择器

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_selected="false" android:drawable="@drawable/ic_launcher" />
    <item android:state_selected="true" android:drawable="@drawable/ic_launcher_round" />
</selector>

 

注:模板有5个tab,需要5个图片选择器,还需要5个文本选择器,还需要创建5个fragment。如果要动态改变文本点击变色,需要用getResources().getColorStateList(R.color.main_bottom_text_selector)才可以,getColor()只会选取一种颜色。

首页 上一页 1 2 下一页 尾页 2/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇[Android][Framework]裁剪SystemS.. 下一篇Android项目实战(五十):微信支..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目