安卓微信页面设计

package com.example.myjob1;

import androidx.appcompat.app.AppCompatActivity;

import android.app.Fragment;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageButton;
import android.widget.LinearLayout;


public class MainActivity extends AppCompatActivity implements View.OnClickListener {

    private Fragment news = new news();
    private Fragment friends = new friends();
    private Fragment address =new address();
    private Fragment setting = new setting();
    private  FragmentManager fragmentManager;
    private LinearLayout linearLayout_news,linearLayout_friends,linearLayout_setting,linearLayout_address;
    private ImageButton news_button,friends_button,address_button,setting_button;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if(getSupportActionBar()!=null)
        {
            getSupportActionBar().hide();
        }
        setContentView(R.layout.activity_main);
        linearLayout_news=findViewById(R.id.weixin);
        linearLayout_friends=findViewById(R.id.tongxunlu);
        linearLayout_setting=findViewById(R.id.faxian);
        linearLayout_address=findViewById(R.id.wo);

        news_button = findViewById(R.id.weixin1);
        friends_button = findViewById(R.id.tongxunlu1);
        address_button = findViewById(R.id.faxian1);
        setting_button = findViewById(R.id.wo1);

        linearLayout_news.setOnClickListener(this);
        linearLayout_friends.setOnClickListener(this);
        linearLayout_setting.setOnClickListener(this);
        linearLayout_address.setOnClickListener(this);

        init_Fragment();

    }

    private void init_Fragment(){
        fragmentManager =getFragmentManager();

        FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
        fragmentTransaction.add(R.id.Frame_container,news);
        fragmentTransaction.add(R.id.Frame_container,friends);
        fragmentTransaction.add(R.id.Frame_container,address);
        fragmentTransaction.add(R.id.Frame_container,setting);
        fragmentTransaction.commit();
        showFragment(0);
        news_button.setImageResource(R.drawable.setting);
    }

    private void hide_Fragment(FragmentTransaction fragmentTransaction)
    {
        fragmentTransaction.hide(news);
        fragmentTransaction.hide(friends);
        fragmentTransaction.hide(address);
        fragmentTransaction.hide(setting);
    }

    @Override
    public void onClick(View view) {
        resetButton();

        switch (view.getId()){
            case R.id.weixin:
                showFragment(0);
                news_button.setImageResource(R.drawable.news);
                break;
            case R.id.tongxunlu:
                showFragment(1);
                friends_button.setImageResource(R.drawable.friends);
                break;
            case R.id.faxian:
                showFragment(2);
                setting_button.setImageResource(R.drawable.setting);
                break;
            case R.id.wo:

                showFragment(3);
                address_button.setImageResource(R.drawable.address);
                break;
            default:
                break;

        }

    }

    private void showFragment(int i) {
        FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
        hide_Fragment(fragmentTransaction);
        switch (i){
            case 0:
                fragmentTransaction.show(news);
                break;
            case 1:
                fragmentTransaction.show(friends);
                break;
            case 2:
                fragmentTransaction.show(setting);
                break;
            case 3 :
                fragmentTransaction.show(address);
                break;
            default:
                break;
        }
        fragmentTransaction.commit();
    }
    private void resetButton(){
        news_button.setImageResource(R.drawable.news);
        friends_button.setImageResource(R.drawable.friends);
        address_button.setImageResource(R.drawable.address);
        setting_button.setImageResource(R.drawable.setting);
    }


}

 

package com.example.myjob1;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import android.app.Fragment;


public class address extends Fragment {

    public address() {
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {

        return inflater.inflate(R.layout.fragment_address, container, false);
    }
}
package com.example.myjob1;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import android.app.Fragment;


public class friends extends Fragment {

    public friends() {

    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {

        return inflater.inflate(R.layout.fragment_friends, container, false);
    }
}

 

package com.example.myjob1;

import android.os.Bundle;

import android.app.Fragment;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;


public class news extends Fragment {

    public news() {

    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {

        return inflater.inflate(R.layout.fragment_news, container, false);
    }
}
package com.example.myjob1;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import android.app.Fragment;


public class setting extends Fragment {

    public setting() {
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_setting, container, false);
    }
}
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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"
    tools:context=".MainActivity">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">
        <include layout="@layout/top"></include>
        <FrameLayout
            android:id="@+id/Frame_container"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1">

        </FrameLayout>

        <include layout="@layout/bottom" />

    </LinearLayout>

</androidx.constraintlayout.widget.ConstraintLayout>

 

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="wrap_content"
    android:layout_height="100dp"
    android:layout_gravity="bottom"
    android:baselineAligned="false"
    android:orientation="horizontal">

    <LinearLayout
        android:id="@+id/weixin"
        android:layout_width="0dp"
        android:layout_height="100dp"
        android:layout_gravity="bottom"
        android:layout_weight="1"
        android:orientation="vertical">


        <ImageButton
            android:id="@+id/weixin1"
            android:layout_width="match_parent"
            android:layout_height="80dp"
            android:background="#EAFAEB"
            android:src="@drawable/news"
            tools:ignore="SpeakableTextPresentCheck"
            tools:src="@drawable/news" />

        <TextView
            android:id="@+id/textView2"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:gravity="center_horizontal"
            android:saveEnabled="false"
            android:text="微信"
            android:textColor="#000000"
            android:textSize="14sp" />


    </LinearLayout>

    <LinearLayout
        android:id="@+id/tongxunlu"
        android:layout_width="0dp"
        android:layout_height="100dp"
        android:layout_gravity="bottom"
        android:layout_weight="1"
        android:orientation="vertical">

        <ImageButton
            android:id="@+id/tongxunlu1"
            android:layout_width="match_parent"
            android:layout_height="80dp"
            android:background="#ffffff"
            android:src="@drawable/friends"
            tools:ignore="SpeakableTextPresentCheck"
            tools:src="@drawable/friends" />

        <TextView
            android:id="@+id/textView3"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:gravity="center_horizontal"
            android:saveEnabled="false"
            android:text="通讯录"
            android:textColor="#000000"
            android:textSize="14sp" />


    </LinearLayout>

    <LinearLayout
        android:id="@+id/faxian"
        android:layout_width="0dp"
        android:layout_height="100dp"
        android:layout_gravity="bottom"
        android:layout_weight="1"
        android:orientation="vertical">

        <ImageButton
            android:id="@+id/faxian1"
            android:layout_width="match_parent"
            android:layout_height="80dp"
            android:background="#ffffff"
            android:src="@drawable/address"
            tools:ignore="SpeakableTextPresentCheck"
            tools:src="@drawable/address" />

        <TextView
            android:id="@+id/textView4"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:gravity="center_horizontal"
            android:saveEnabled="false"
            android:text="发现"
            android:textColor="#000000"
            android:textSize="14sp" />


    </LinearLayout>

    <LinearLayout
        android:id="@+id/wo"
        android:layout_width="0dp"
        android:layout_height="100dp"
        android:layout_gravity="bottom"
        android:layout_weight="1"
        android:orientation="vertical">

        <ImageButton
            android:id="@+id/wo1"
            android:layout_width="wrap_content"
            android:layout_height="80dp"
            android:background="#ffffff"
            android:src="@drawable/setting"
            tools:ignore="SpeakableTextPresentCheck"
            tools:src="@drawable/setting" />

        <TextView
            android:id="@+id/textView5"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:gravity="center_horizontal"
            android:saveEnabled="false"
            android:text="我"
            android:textColor="#000000"
            android:textSize="14sp" />


    </LinearLayout>

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

    <!-- TODO: Update blank fragment layout -->
    <TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="center"
        android:textSize="40sp"
        android:textColor="@color/black"
        android:text="@string/address_blank_fragment" />

</LinearLayout>

 

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

    <!-- TODO: Update blank fragment layout -->
    <TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="center"
        android:textSize="40sp"
        android:textColor="@color/black"
        android:text="@string/friend_blank_fragment" />

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

    <!-- TODO: Update blank fragment layout -->
    <TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="center"
        android:textSize="40sp"
        android:textColor="@color/black"
        android:text="@string/hello_blank_fragment" />

</LinearLayout>

 

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

    <!-- TODO: Update blank fragment layout -->
    <TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="center"
        android:textSize="40sp"
        android:textColor="@color/black"
        android:text="@string/setting_blank_fragment" />

</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="65dp"
    android:gravity="center"
    android:background="@color/white"
    android:orientation="vertical"

    >

    <TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="center"
        android:text="微信"
        android:textColor="@color/black"
        android:textSize="25sp" />

</LinearLayout>

 

仓库地址:wymqwer/mywork6: logs (github.com)

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值