android studio 实现简单的微信布局跳转

这篇博客介绍如何使用fragment布局在Android Studio中创建一个简单的微信样式页面跳转。作者提供了码云上的代码资源,并详细阐述了设计过程,包括top和bottom布局的创建,底部按钮的设置以及主页面的实现。在Java代码部分,强调了MainActivity中的点击事件处理,特别是避免因imagebutton和textview遮挡导致的点击事件问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

采用fragment布局,写了一个简单的微信跳转页面

在码云中放了部分代码,整个java文件夹和res文件夹里layout文件夹
https://gitee.com/kadd/android

接下来开始具体介绍整体的设计过程:
目标:简易的根据图标来进行页面的跳转

1.首先先写好两个固定的部分,top和bottom
top.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/ID_top"
    android:layout_width="match_parent"
    android:layout_height="55dp"
    android:orientation="horizontal">

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="55dp"
        android:layout_weight="1"
        android:background="@android:color/background_dark"
        android:text="WeChat"
        android:gravity="center"
        android:textColor="@android:color/background_light"
        android:textSize="35sp" />

</LinearLayout>

2.botto部分相对来说,比较复杂,这里以linearlaout为基础布局,再布置4个linearlaout作为四个button的laout,以简单的imagebutton加textview的组合构造一个按钮。具体代码如下(这里只放出了一个button的代码):
bottom.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="85dp"
    android:background="@drawable/bottom_bar"
    android:orientation="horizontal">


    <LinearLayout
        android:id="@+id/id_tab_lay_wechat"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:gravity="center"
        android:orientation="vertical">

        <ImageButton
            android:id="@+id/id_tab_weixin"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:clickable="false"
            android:background="@android:color/transparent"
            app:srcCompat="@drawable/tab_weixin_pressed" />

        <TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="微信"
            android:clickable="false"
            an
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值