android底部导航栏+viewPager+自定义view的简单实现

底部导航栏
摘要由CSDN通过智能技术生成

Ps:导航栏直接用Android Design Library,导航栏的话用TabLayout实现,是比较方便快捷的方法。以下仅供初学者学习。。。。一年后回过来看写的比较糟糕

这里写图片描述

1首先我们要解决界面的问题,也就是先让用户能看到界面,再来搞定能不能用的问题是吧。首先是下面导航栏,我第第一反应就是想到一个ImageView+TextView的组合,也就是用到了组合控件,这里我叫它phototext.xml。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:tools="http://schemas.android.com/tools">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:layout_centerVertical="true">

        <ImageView
            android:id="@+id/photo"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_centerVertical="true"
            tools:src="@mipmap/ic_launcher"/>

        <TextView
            android:id="@+id/photo_text"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            tools:text="男"/>   
    </LinearLayout>
</RelativeLayout>

有了布局文件,那么就要有java文件嘛,因为自定义,不然的话上面布局就是死的,不可以自己自定义了。java文件自然也叫PhotoText.java,很好听吧。。突然觉得我是取名字的天才。。。

public 
  • 2
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值