TextView+ImageView+LinearLayout实现底部导航栏

效果图:


activity_main.xml布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"
    tools:context="com.myapplication.activity.MainActivity">
    <FrameLayout
        android:id="@+id/fl_fragment_content"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:background="#bababa"
        android:layout_weight="1">
        <!-- 存放四个Fragment-->
    </FrameLayout>

    <!-- 底部的四个选项菜单-->
    <LinearLayout
        android:background="#ffffff"
        android:layout_width="match_parent"
        android:layout_height="49dp">
        <!--四个部分都一样:ImageView + TextView-->
        <RelativeLayout
            android:id="@+id/rl_first_layout"
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="match_parent"
            android:gravity="center">
            <ImageView
                android:id="@+id/iv_first_home"
                android:src="@drawable/icon_homepage_selector"
                android:layout_width="24dp"
                android:layout_centerHorizontal="true"
                android:layout_height="24dp" />
            <TextView
                android:id="@+id/tv_first_home"
                android:textColor="@drawable/text_selector_color"
                android:text="首页"
                android:layout_below="@+id/iv_first_home"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerHorizontal="true"
                android:layout_gravity="center_horizontal"/>
        </RelativeLayout>

        <RelativeLayout
            android:id="@+id/rl_second_layout"
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="match_parent"
            android:gravity="center">
            <ImageView
                android:id="@+id/iv_second_match"
                android:src="@drawable/icon_matchpage_selector"
                android:layout_centerHorizontal="true"
                android:layout_width="24dp"
                android:layout_height="24dp" />
            <TextView
                android:id="@+id/tv_second_match"
                android:textColor="@drawable/text_selector_color"
                android:text="赛程"
                android:layout_below="@+id/iv_second_match"
                android:layout_centerHorizontal="true"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal"/>
        </RelativeLayout>

        <RelativeLayout
            android:id="@+id/rl_third_layout"
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="match_parent"
            android:gravity="center">
            <ImageView
                android:id="@+id/iv_third_recommend"
                android:src="@drawable/icon_recommendpage_selector"
                android:layout_centerHorizontal="true"
                android:layout_width="24dp"
                android:layout_height="24dp" />
            <TextView
                android:id="@+id/tv_third_recommend"
                androi
  • 4
    点赞
  • 22
    收藏
    觉得还不错? 一键收藏
  • 6
    评论
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值