Accounting APP: Xiaoha Accounting 1 - Production of welcome page

Project Introduction:

        Xiaoha Bookkeeping is an app for bookkeeping, based on the Android Studio development tool, using the Java language for development, and using litepal and Alibaba Cloud database to add, delete, check and modify data, and display it on the app interface in the form of icons. The app can clearly display the income and expenditure situation, and display the monthly income and expenditure situation in the form of a chart; at the same time, it can record consumption purposes, and the project can accurately track the income and expenditure time and balance of each payment, and can set a monthly budget. Reminders of exceeding the budget, and weekly, monthly and annual bill statistics, which are more clear and clear to help users analyze their current expenditure and income. At the same time, it has functions such as user login, registration, and modification of avatar.

        Technologies used in this project: LitePal database, Alibaba Cloud RDS database, MPAndroidChart chart library, some custom controls, etc.

        Support Android 5.0 and above.

        This article will introduce the welcome page creation of Xiaoha Accounting.

Renderings:

source code:

activity_welcome.xml file

This file is used to set the layout of the welcome page. This case consists of two ImageView controls and one TextView control.

The two ImageView controls are used to store the background image and LOGO respectively, and the TextView control is used to store the welcome statement.

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

    <ImageView
        android:id="@+id/s1"
        android:layout_width="match_parent"
        android:layout_height="560sp"
        android:layout_alignParentTop="true"
        android:background="@drawable/welcome_top"
        android:scaleType="fitXY"/>

    <ImageView
        android:layout_width="220sp"
        android:layout_height="44sp"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:layout_marginBottom="30sp"
        android:background="@drawable/login_logo2" />

    <TextView
        android:id="@+id/welcome_text"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="50sp"
        android:text="这世界有那么多人\n\n         多幸运我有个我们"
        android:textColor="@color/white"
        android:textSize="24sp" />

</RelativeLayout>

WelcomeActivity.java

This file is used to implement the welcome page function, which is set in the onCreate function to jump to the main page after the page stays for 3 seconds.

package com.example.xiaohaaccounting.Activity;

import androidx.annotation.NonNull;

import android.content.Intent;
import android.graphics.Typeface;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.widget.TextView;

import com.example.xiaohaaccounting.R;
import com.example.xiaohaaccounting.Utils_class.MyAppCompatActivity;

public class WelcomeActivity extends MyAppCompatActivity {

    private Handler handler = new Handler(){
        @Override
        public void handleMessage(@NonNull Message msg) {
            switch (msg.what){
                case 1:
                    startActivity(new Intent(WelcomeActivity.this, LoginActivity.class));
                    WelcomeActivity.this.finish();
                    break;
                case 2:
                    break;
                default:
                    break;
            }
        }
    };

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_welcome);

        TextView welcome_text = (TextView) findViewById(R.id.welcome_text);
        Typeface typeface = Typeface.createFromAsset(getAssets(),"qingcha_kaiti.ttf");//文本字体
        welcome_text.setTypeface(typeface);
        handler.sendEmptyMessageDelayed(1,1000*3);//停留3s
    }

}

MyAppCompatActivity.java

This file is a custom general AppCompatActivity file in this project, which is used to set the top status bar to be transparent, and record the creation and destruction of activities (for the subsequent logout function to pave the way).

package com.example.xiaohaaccounting.Utils_class;

import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;

import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;

/**
 * 我的Activity
 * 顶部状态栏透明
 * 记录活动创建销毁
 * */

public class MyAppCompatActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ActivityCollector.addActivity(this);

        if (Build.VERSION.SDK_INT >= 21) {//21表示5.0
            Window window = getWindow();
            window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
            window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                    | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
            window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
            window.setStatusBarColor(Color.TRANSPARENT);
        } else if (Build.VERSION.SDK_INT >= 19) {//19表示4.4
            getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        }

        ActionBar actionBar = getSupportActionBar();
        if(actionBar != null){
            actionBar.hide();
        }
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        ActivityCollector.removeActivity(this);
    }

}

After writing the above three files, the welcome page is ready, but at this time, because the login page (LoginActivity.java) has not been made yet, there will be problems with the welcome page jump. The production of the login page will be in the third article for details.

Guess you like

Origin blog.csdn.net/Me_Rui/article/details/125925187