Step 1 MAIN.XML

<?xml version="1.0" encoding="utf-8"?>

<ScrollView 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:background="#46244C"

    tools:context=".BMI_Test_page1">




    <androidx.constraintlayout.widget.ConstraintLayout

        android:layout_width="match_parent"

        android:layout_height="wrap_content">


        <androidx.cardview.widget.CardView

            android:id="@+id/cardView_male"

            android:layout_width="0dp"

            android:layout_height="wrap_content"

            android:layout_marginStart="16dp"

            android:layout_marginLeft="16dp"

            android:layout_marginTop="32dp"

            android:layout_marginEnd="8dp"

            android:layout_marginRight="8dp"

            app:cardCornerRadius="10dp"

            app:layout_constraintHorizontal_weight="1"

            app:cardBackgroundColor="#333C83"

            app:layout_constraintBottom_toTopOf="@+id/cardView5"

            app:layout_constraintEnd_toStartOf="@+id/cardView_female"

            app:layout_constraintHorizontal_chainStyle="spread"

            app:layout_constraintStart_toStartOf="parent"

            app:layout_constraintTop_toTopOf="parent">


            <TextView

                android:id="@+id/male"

                android:layout_width="wrap_content"

                android:layout_height="wrap_content"

                android:layout_gravity="center|bottom"

                android:drawablePadding="5sp"

                android:padding="20dp"

                android:text="@string/male"

                android:textAlignment="center"

                android:textColor="@color/tint"

                android:textSize="20sp"

                android:textStyle="bold"

                app:drawableTopCompat="@drawable/male" />


        </androidx.cardview.widget.CardView>


        <androidx.cardview.widget.CardView

            android:id="@+id/cardView_female"

            android:layout_width="0dp"

            android:layout_height="wrap_content"

            android:layout_marginEnd="16dp"

            android:layout_marginRight="16dp"

            app:layout_constraintHorizontal_weight="1"

            app:cardBackgroundColor="#333C83"

            app:cardCornerRadius="10dp"

            app:layout_constraintBottom_toBottomOf="@+id/cardView_male"

            app:layout_constraintEnd_toEndOf="parent"

            app:layout_constraintStart_toEndOf="@+id/cardView_male"

            app:layout_constraintTop_toTopOf="@+id/cardView_male">


            <TextView

                android:id="@+id/female"

                android:layout_width="wrap_content"

                android:layout_height="wrap_content"

                android:layout_gravity="center|bottom"

                android:drawablePadding="5sp"

                android:padding="20dp"

                android:text="female"

                android:textAlignment="center"

                android:textColor="@color/tint"

                android:textSize="20sp"

                android:textStyle="bold"

                app:drawableTopCompat="@drawable/female" />


        </androidx.cardview.widget.CardView>


        <androidx.cardview.widget.CardView

            android:id="@+id/cardView5"

            android:layout_width="match_parent"

            android:layout_height="wrap_content"

            android:layout_margin="16dp"

            app:cardBackgroundColor="#333C83"

            app:cardCornerRadius="10dp"

            app:layout_constraintBottom_toTopOf="@+id/cardView3"

            app:layout_constraintHorizontal_chainStyle="spread"

            app:layout_constraintLeft_toLeftOf="parent"

            app:layout_constraintRight_toRightOf="parent"

            app:layout_constraintTop_toBottomOf="@+id/cardView_male">


            <LinearLayout

                android:layout_width="match_parent"

                android:layout_height="wrap_content"

                android:gravity="center"

                android:orientation="vertical"

                android:padding="20dp">


                <TextView

                    android:layout_width="wrap_content"

                    android:layout_height="wrap_content"

                    android:text="height"

                    android:textColor="#8D8E99"

                    android:textSize="20sp"

                    android:textStyle="bold" />


                <TextView

                    android:id="@+id/height_txt"

                    android:layout_width="wrap_content"

                    android:layout_height="wrap_content"

                    android:text="0cm"

                    android:textColor="@android:color/white"

                    android:textSize="50sp"

                    android:textStyle="bold" />


                <SeekBar

                    android:id="@+id/Seekbar"

                    style="?android:attr/progressBarStyleHorizontal"

                    android:layout_width="match_parent"

                    android:layout_height="wrap_content"

                    android:layout_marginTop="10dp"

                    android:max="200"

                    android:progressBackgroundTint="#888994"

                    android:progressTint="@android:color/white"

                    tools:targetApi="lollipop" />


            </LinearLayout>


        </androidx.cardview.widget.CardView>


        <androidx.cardview.widget.CardView

            android:id="@+id/cardView3"

            android:layout_width="0dp"

            android:layout_height="wrap_content"

            android:layout_marginStart="16dp"

            android:layout_marginLeft="16dp"

            android:layout_marginEnd="8dp"

            android:layout_marginRight="8dp"

            app:layout_constraintHorizontal_weight="1"

            app:cardBackgroundColor="#333C83"

            app:cardCornerRadius="10dp"

            app:layout_constraintBottom_toTopOf="@+id/calculate"

            app:layout_constraintEnd_toStartOf="@+id/cardView4"

            app:layout_constraintStart_toStartOf="parent"

            app:layout_constraintTop_toBottomOf="@+id/cardView5">


            <LinearLayout

                android:layout_width="match_parent"

                android:layout_height="wrap_content"

                android:gravity="center_horizontal"

                android:orientation="vertical"

                android:padding="15dp">


                <TextView

                    android:layout_width="wrap_content"

                    android:layout_height="wrap_content"

                    android:text="weight"

                    android:textColor="#8D8E99"

                    android:textSize="20sp"

                    android:textStyle="bold" />


                <TextView

                    android:id="@+id/weight"

                    android:layout_width="wrap_content"

                    android:layout_height="wrap_content"

                    android:layout_gravity="center"

                    android:text="50"

                    android:textColor="@android:color/white"

                    android:textSize="50sp"

                    android:textStyle="bold" />


                <LinearLayout

                    android:layout_width="wrap_content"

                    android:layout_height="wrap_content"

                    android:layout_marginTop="8dp"

                    android:baselineAligned="false"

                    android:gravity="center_horizontal"

                    android:weightSum="2">


                    <RelativeLayout

                        android:id="@+id/weight_minus"

                        android:layout_width="wrap_content"

                        android:layout_height="wrap_content"

                        android:layout_marginEnd="5dp"

                        android:layout_marginRight="5dp"

                        android:layout_weight="1"

                        android:background="@drawable/stepper_background">


                        <ImageView

                            android:layout_width="60dp"

                            android:layout_height="60dp"

                            android:contentDescription="minus"

                            android:padding="14dp"

                            app:srcCompat="@drawable/substract" />


                    </RelativeLayout>



                    <RelativeLayout

                        android:id="@+id/weight_plus"

                        android:layout_width="wrap_content"

                        android:layout_height="wrap_content"

                        android:layout_marginStart="5dp"

                        android:layout_marginLeft="5dp"

                        android:layout_weight="1"

                        android:background="@drawable/stepper_background">


                        <ImageView

                            android:layout_width="60dp"

                            android:layout_height="60dp"

                            android:contentDescription="plus"

                            android:padding="3dp"

                            app:srcCompat="@drawable/ic_add" />


                    </RelativeLayout>


                </LinearLayout>


            </LinearLayout>


        </androidx.cardview.widget.CardView>


        <androidx.cardview.widget.CardView

            android:id="@+id/cardView4"

            android:layout_width="0dp"

            android:layout_height="wrap_content"

            android:layout_marginEnd="16dp"

            android:layout_marginRight="16dp"

            app:cardBackgroundColor="#333C83"

            app:cardCornerRadius="10dp"

            app:layout_constraintHorizontal_weight="1"

            app:layout_constraintBottom_toBottomOf="@+id/cardView3"

            app:layout_constraintEnd_toEndOf="parent"

            app:layout_constraintStart_toEndOf="@+id/cardView3"

            app:layout_constraintTop_toTopOf="@+id/cardView3">


            <LinearLayout

                android:layout_width="match_parent"

                android:layout_height="wrap_content"

                android:gravity="center_horizontal"

                android:orientation="vertical"

                android:padding="15dp">


                <TextView

                    android:layout_width="wrap_content"

                    android:layout_height="wrap_content"

                    android:gravity="center"

                    android:text="age"

                    android:textColor="#8D8E99"

                    android:textSize="20sp"

                    android:textStyle="bold" />


                <TextView

                    android:id="@+id/age"

                    android:layout_width="wrap_content"

                    android:layout_height="wrap_content"

                    android:text="19"

                    android:textColor="@android:color/white"

                    android:textSize="50sp"

                    android:textStyle="bold" />


                <LinearLayout

                    android:layout_width="wrap_content"

                    android:layout_height="wrap_content"

                    android:layout_marginTop="8dp"

                    android:baselineAligned="false"

                    android:gravity="center_horizontal"

                    android:weightSum="2">


                    <RelativeLayout

                        android:id="@+id/age_minus"

                        android:layout_width="wrap_content"

                        android:layout_height="wrap_content"

                        android:layout_marginEnd="5dp"

                        android:layout_marginRight="5dp"

                        android:layout_weight="1"

                        android:background="@drawable/stepper_background">


                        <ImageView

                            android:layout_width="60dp"

                            android:layout_height="60dp"

                            android:contentDescription="minus"

                            android:padding="14dp"

                            app:srcCompat="@drawable/substract" />


                    </RelativeLayout>



                    <RelativeLayout

                        android:id="@+id/age_plus"

                        android:layout_width="wrap_content"

                        android:layout_height="wrap_content"

                        android:layout_marginStart="5dp"

                        android:layout_marginLeft="5dp"

                        android:layout_weight="1"

                        android:background="@drawable/stepper_background">


                        <ImageView

                            android:layout_width="60dp"

                            android:layout_height="60dp"

                            android:contentDescription="plus"

                            android:padding="3dp"

                            app:srcCompat="@drawable/ic_add" />


                    </RelativeLayout>


                </LinearLayout>


            </LinearLayout>


        </androidx.cardview.widget.CardView>


        <Button

            android:id="@+id/calculate"

            android:layout_width="match_parent"

            android:layout_height="55dp"

            android:layout_marginLeft="16dp"

            android:layout_marginTop="16dp"

            android:layout_marginRight="16dp"

            android:layout_marginBottom="24dp"

            android:background="@drawable/calculate_btn"

            android:text="calculate"

            android:textColor="@android:color/black"

            android:textSize="17sp"

            android:textStyle="bold"

            app:layout_constraintBottom_toBottomOf="parent"

            app:layout_constraintEnd_toEndOf="parent"

            app:layout_constraintHorizontal_bias="0.5"

            app:layout_constraintStart_toStartOf="parent"

            app:layout_constraintTop_toBottomOf="@+id/cardView3" />


    </androidx.constraintlayout.widget.ConstraintLayout>



</ScrollView>


Step 2 MAIN.JAVA

package org.tensorflow.lite.examples.classification;


import androidx.appcompat.app.AppCompatActivity;

import androidx.cardview.widget.CardView;


import android.content.Intent;

import android.graphics.Color;

import android.os.Bundle;

import android.view.View;

import android.widget.Button;

import android.widget.RelativeLayout;

import android.widget.SeekBar;

import android.widget.TextView;


public class BMI_Test_page1 extends AppCompatActivity {

    float height,weight;

    TextView height_txt,age;

    int count_weight = 50,count_age = 19;

    RelativeLayout weight_plus, weight_minus, age_plus, age_minus;

    boolean male_clk = true, female_clk = true, check1 = true, check2 = true;

    @Override

    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_bmi_test_page1);

        height_txt = findViewById(R.id.height_txt);


        final TextView female_text = findViewById(R.id.female);

        final TextView male_text = findViewById(R.id.male);


        CardView card_female = findViewById(R.id.cardView_female);

        CardView card_male = findViewById(R.id.cardView_male);


        age_minus = findViewById(R.id.age_minus);

        age_plus = findViewById(R.id.age_plus);


        weight_minus = findViewById(R.id.weight_minus);

        weight_plus = findViewById(R.id.weight_plus);


        card_male.setOnClickListener(new View.OnClickListener() {

            @Override

            public void onClick(View v) {

                if (check1) {


                    if (male_clk) {


                        male_text.setTextColor(Color.parseColor("#FFFFFF"));

                        male_text.setCompoundDrawablesWithIntrinsicBounds(0,R.drawable.male_white,0,0);

                        male_clk = false;

                        check2 = false;


                    } else {


                        male_text.setTextColor(Color.parseColor("#8D8E99"));

                        male_text.setCompoundDrawablesWithIntrinsicBounds(0,R.drawable.male,0,0);

                        male_clk = true;

                        check2 = true;

                    }

                }

            }

        });


        card_female.setOnClickListener(new View.OnClickListener() {

            @Override

            public void onClick(View v) {

                if (check2) {

                    if (female_clk) {

                        female_text.setTextColor(Color.parseColor("#FFFFFF"));

                        female_text.setCompoundDrawablesWithIntrinsicBounds(0,R.drawable.female_white,0,0);

                        female_clk = false;

                        check1 = false;

                    }

                    else  {


                        female_text.setTextColor(Color.parseColor("#8D8E99"));

                        female_text.setCompoundDrawablesWithIntrinsicBounds(0,R.drawable.female,0,0);

                        female_clk = true;

                        check1 = true;

                    }

                }

            }

        });


        CheckSeekbarStatus();


        CheckWeight();


        CheckAge();


        Button calculate = findViewById(R.id.calculate);

        calculate.setOnClickListener(new View.OnClickListener() {

            @Override

            public void onClick(View v) {

                CalculateBMI();

            }

        });


    }



    private void CheckAge() {


        age = findViewById(R.id.age);


        age_plus.setOnClickListener(new View.OnClickListener() {

            @Override

            public void onClick(View v) {

                count_age++;

                age.setText(String.valueOf(count_age));

            }

        });


        age_minus.setOnClickListener(new View.OnClickListener() {

            @Override

            public void onClick(View v) {

                count_age--;

                age.setText(String.valueOf(count_age));

            }

        });

    }


    private void CheckWeight() {


        final TextView weight_txt = findViewById(R.id.weight);


        weight_plus.setOnClickListener(new View.OnClickListener() {

            @Override

            public void onClick(View v) {

                count_weight++;

                weight_txt.setText(String.valueOf(count_weight));

            }

        });


        weight_minus.setOnClickListener(new View.OnClickListener() {

            @Override

            public void onClick(View v) {

                count_weight--;

                weight_txt.setText(String.valueOf(count_weight));

            }

        });


        weight = Float.parseFloat(weight_txt.getText().toString());


    }


    private void CheckSeekbarStatus() {


        SeekBar Seekbar = findViewById(R.id.Seekbar);

        Seekbar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {

            @Override

            public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {

                String ht = progress + getResources().getString(R.string.cm);

                height_txt.setText(ht);

                height = (float)(progress)/100;

            }


            @Override

            public void onStartTrackingTouch(SeekBar seekBar) {


            }


            @Override

            public void onStopTrackingTouch(SeekBar seekBar) {


            }

        });

    }


    private void CalculateBMI() {


        float BMI = weight / (height * height);

        Intent intent = new Intent(BMI_Test_page1.this,ResultActivity1.class);

        intent.putExtra("BMI",BMI);

        intent.putExtra("age",age.getText().toString());

        startActivity(intent);

    }


Step 3  RESULTACTIVITY.XML

<?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"

    android:background="@color/background"

    tools:context=".ResultActivity1">



    <TextView

        android:id="@+id/textView"

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:text="your result"

        android:textColor="@android:color/white"

        android:textSize="40sp"

        android:layout_margin="16dp"

        android:textStyle="bold"

        android:layout_marginLeft="16dp"

        android:layout_marginRight="16dp"

        app:layout_constraintBottom_toTopOf="@+id/result_card"

        app:layout_constraintStart_toStartOf="parent"

        app:layout_constraintTop_toTopOf="parent" />


    <androidx.cardview.widget.CardView

        android:id="@+id/result_card"

        android:layout_width="match_parent"

        android:layout_height="wrap_content"

        android:layout_marginLeft="16dp"

        android:layout_marginTop="16dp"

        android:layout_marginRight="16dp"

        app:cardBackgroundColor="@color/card_background"

        app:cardCornerRadius="20sp"

        app:layout_constraintEnd_toEndOf="parent"

        app:layout_constraintHorizontal_bias="0.5"

        app:layout_constraintStart_toStartOf="parent"

        app:layout_constraintTop_toBottomOf="@+id/textView">


        <LinearLayout

            android:layout_width="match_parent"

            android:layout_height="wrap_content"

            android:gravity="center"

            android:orientation="vertical"

            android:padding="20dp">


            <TextView

                android:id="@+id/condition"

                android:layout_width="wrap_content"

                android:layout_height="wrap_content"

                android:layout_marginTop="20sp"

                android:textColor="#5ADC65"

                android:textSize="20sp"

                android:textStyle="bold" />


            <TextView

                android:id="@+id/your_bmi"

                android:layout_width="wrap_content"

                android:layout_height="wrap_content"

                android:layout_marginTop="10dp"

                android:textColor="@android:color/white"

                android:textSize="50sp"

                android:textStyle="bold" />


            <TextView

                android:layout_width="wrap_content"

                android:layout_height="wrap_content"

                android:layout_marginTop="16dp"

                android:text="normal bmi range"

                android:textColor="#8D8E99"

                android:textSize="21sp"

                android:textStyle="bold" />


            <TextView

                android:layout_width="wrap_content"

                android:layout_height="wrap_content"

                android:text="@string/_18_5_25_kg_m2"

                android:textColor="@android:color/white"

                android:textSize="20sp"

                android:textStyle="bold" />


            <TextView

                android:layout_width="wrap_content"

                android:layout_height="wrap_content"

                android:layout_marginTop="16dp"

                android:text="your age"

                android:textColor="@color/colorAccent"

                android:textSize="20sp"

                android:textStyle="bold" />


            <TextView

                android:id="@+id/age"

                android:layout_width="wrap_content"

                android:layout_height="wrap_content"

                android:textColor="@android:color/white"

                android:textSize="20sp" />


            <TextView

                android:id="@+id/category"

                android:layout_width="wrap_content"

                android:layout_height="wrap_content"

                android:layout_marginTop="16dp"

                android:layout_marginBottom="8dp"

                android:gravity="center_horizontal"

                android:textColor="@android:color/white"

                android:textSize="20sp" />


        </LinearLayout>


    </androidx.cardview.widget.CardView>


    <Button

        android:id="@+id/recalculate"

        android:layout_width="match_parent"

        android:layout_height="55dp"

        android:layout_marginLeft="16dp"

        android:layout_marginRight="16dp"

        android:layout_marginBottom="32dp"

        android:background="@drawable/calculate_btn"

        android:text="recalculate"

        android:textColor="@android:color/white"

        android:textSize="17sp"

        android:textStyle="bold"

        app:layout_constraintBottom_toBottomOf="parent"

        app:layout_constraintEnd_toEndOf="parent"

        app:layout_constraintHorizontal_bias="0.5"

        app:layout_constraintStart_toStartOf="parent" />



</androidx.constraintlayout.widget.ConstraintLayout>


Step 3  RESULTACTIVITY.JAVA

package org.tensorflow.lite.examples.classification;


import androidx.appcompat.app.AppCompatActivity;


import android.content.Intent;

import android.os.Bundle;

import android.view.View;

import android.widget.Button;

import android.widget.TextView;


public class ResultActivity1 extends AppCompatActivity {


    @Override

    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_result1);


        Intent intent = getIntent();


        float BMI  = Math.round((intent.getFloatExtra("BMI", 0) * 100) / 100);

        String age_value = intent.getStringExtra("age");


        TextView your_bmi = findViewById(R.id.your_bmi);

        your_bmi.setText(String.valueOf(BMI));


        TextView age = findViewById(R.id.age);

        age.setText(age_value);


        TextView category = findViewById(R.id.category);

        Category category1 = new Category();

        category.setText(category1.getCategory(BMI));


        TextView condition = findViewById(R.id.condition);

        Condition condition1 = new Condition();

        condition.setText(condition1.getCategory(BMI));


        Button recalculate = findViewById(R.id.recalculate);

        recalculate.setOnClickListener(new View.OnClickListener() {

            @Override

            public void onClick(View v) {

                updateUI();

            }

        });


    }


    private void updateUI() {

        Intent intent1 = new Intent(ResultActivity1.this,BMI_Test_page1.class);

        startActivity(intent1);

        fileList();

    }


    @Override

    public void onBackPressed() {

        super.onBackPressed();

        updateUI();

    }

}


GITHUB: https://github.com/LearncodeWithRk/BMI