zoukankan      html  css  js  c++  java
  • 家庭记账本APP开发准备(二)

    今天学习了选项卡,为记账本的分类做了准备。主登录界面进行了优化,但仍未实现各个组件之间的跳转。

    选项卡

    activity_main.xml

    <?xml version="1.0" encoding="utf-8"?>
    <TabHost 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:id="@android:id/tabhost"
        tools:context=".MainActivity">
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">
            <TabWidget
                android:layout_height="wrap_content"
                android:layout_width="match_parent"
                android:id="@android:id/tabs"
    
                ></TabWidget>
            <FrameLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:id="@android:id/tabcontent"
                ></FrameLayout>
        </LinearLayout>
    
    
    </TabHost>
    

      tab1.xml

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:id="@+id/left"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <ImageView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:src="@drawable/bg"/>
    
    </LinearLayout>
    

      tab2.xml

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:id="@+id/right"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <ImageView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:src="@drawable/img"/>
    
    </LinearLayout>
    

      MainActivity.java

    package com.example.xuanxiang;
    
    import androidx.appcompat.app.AppCompatActivity;
    
    import android.os.Bundle;
    import android.view.LayoutInflater;
    import android.widget.TabHost;
    
    public class MainActivity extends AppCompatActivity {
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            TabHost tabHost =(TabHost) findViewById(android.R.id.tabhost);
            tabHost.setup();//初始化 添加标签页
            LayoutInflater inflater =LayoutInflater.from(this);
            inflater.inflate(R.layout.tab1,tabHost.getTabContentView());
            inflater.inflate(R.layout.tab2,tabHost.getTabContentView());
            tabHost.addTab(tabHost.newTabSpec("tab1").setIndicator("选项一").setContent(R.id.left));
            tabHost.addTab(tabHost.newTabSpec("tab2").setIndicator("选项二").setContent(R.id.right));
        }
    }
    

      优化美化后的主界面..........

  • 相关阅读:
    确保消息产生前数据库操作已提交
    信息披露和公司简介总结
    1、清空所有,给当前添加/2、清空上一个,给当前添加。
    不能作为判断条件的:
    excel表格 函数功能
    一种ui app写法
    正则中使用变量及数组去重的方法
    鼠标锁定(消失),进入无限滚动状态
    transform 的旋转 ,3d效果,要添加3d效果的父级加上景深perspective。 3d效果的容器加上 transform-style:preserve-3d。
    rem布局,在用户调整手机字体大小/用户调整浏览器字体大小后,布局错乱问题
  • 原文地址:https://www.cnblogs.com/zzmds/p/12289076.html
Copyright © 2011-2022 走看看