A newcomer tries to summarize the Android view (beginner Android application development)

Introduction

"[Android App Development Textbook](https://www.amazon.co.jp/%E5%9F%BA%E7%A4%8E%EF%BC%86%E5%BF%9C%E7%94%" A8% E5% 8A% 9B% E3% 82% 92% E3% 81% 97% E3% 81% A3% E3% 81% 8B% E3% 82% 8A% E8% 82% B2% E6% 88% 90% EF% BC% 81-Android% E3% 82% A2% E3% 83% 97% E3% 83% AA% E9% 96% 8B% E7% 99% BA% E3% 81% AE% E6% 95% 99% E7% A7% 91% E6% 9B% B8-% E3% 81% AA% E3% 82% 93% E3% 81% A1% E3% 82% 83% E3% 81% A3% E3% 81% A6% E9 % 96% 8B% E7% 99% BA% E8% 80% 85% E3% 81% AB% E3% 81% AA% E3% 82% 89% E3% 81% AA% E3% 81% 84% E3% 81 % 9F% E3% 82% 81% E3% 81% AE% E5% AE% 9F% E8% B7% B5% E3% 83% 8F% E3% 83% B3% E3% 82% BA% E3% 82% AA % E3% 83% B3-WINGS% E3% 83% 97% E3% 83% AD% E3% 82% B8% E3% 82% A7% E3% 82% AF% E3% 83% 88% E9% BD% 8A % E8% 97% A4-% E6% 96% B0% E4% B8% 89-ebook / dp / B078X8H61T / ref = sr_1_2? __mk_ja_JP =% E3% 82% AB% E3% 82% BF% E3% 82% AB % E3% 83% 8A & dchild = 1 & keywords = Android% E3% 82% A2% E3% 83% 97% E3% 83% AA% E9% 96% 8B% E7% 99% BA% E3% 81% AE% E6% 95 % 99% E7% A7% 91% E6% 9B% B8 & qid = 1587897459 & sr = 8-2 "Android App Development Textbook") "

Now that I've finished all the steps, this time I'll explain the view using images.

background

It's been 3 months since I changed my job to Sier. It's been a month since I was assigned to the site after the training. I'm studying Android apps that I'll be using in the future, so I'll write them in the output. I'm an amateur.

Development environment

androidstudio 3.6.2 openjdk version "11.0.6"

Anyway sample

Make a screen like this. キャプチャ1.PNG

A view is a screen component. Also called a widget. On the above screen, "Enter your name" is also a view, a button to select male or female (radio button) is also a view, and a list of drinks is also a view.

When this is coded, it looks like this.

res/values/string.xml


<resources>
    <string name="app_name">Screen parts sample</string>
    <string name="tv_msg">Please enter your name.</string>
    <string name="bt_save">Save</string>
    <string name="cb_drink">Drink</string>
    <string name="cb_food">Hood</string>
    <string name="rb_male">Man</string>
    <string name="rb_female">woman</string>
    <string-array name="dlinkllist">
        <item>Cola</item>
        <item>Oolong Tea</item>
        <item>cocoa</item>
        <item>Vegetable juice</item>
    </string-array>
</resources>

This is where you enter the text you want to display in each view. If you enter this name = "○○" ○○ in the text attribute below as shown in the sample, you can use it as the text in the entered view.

res/layout/activity_main.xml



<?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="match_parent"
    android:background="#A1A9BA"
    android:orientation="vertical">

    <TextView
        android:id="@+id/tvLabelInput"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="10dp"
        android:layout_marginTop="5dp"
        android:background="#ffffff"
        android:text="@string/tv_msg"
        android:textSize="25sp"/>

    <EditText
        android:id="@+id/etInput"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="25dp"
        android:layout_marginTop="5dp"
        android:background="#ffffff"
        android:inputType="text"/>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="#df7401"
        android:orientation="horizontal">

        <CheckBox
            android:id="@+id/cbDrink"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginRight="25dp"
            android:background="#ffffff"
            android:text="@string/cb_drink"/>

        <CheckBox
            android:id="@+id/cbFood"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="#ffffff"
            android:text="@string/cb_food"/>
    </LinearLayout>

    <RadioGroup
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="10dp"
        android:layout_marginTop="10dp"
        android:background="#df7401"
        android:orientation="horizontal"
        android:paddingBottom="10dp"
        android:paddingTop="10dp">

        <RadioButton
            android:id="@+id/rbMale"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="25dp"
            android:layout_marginRight="25dp"
            android:background="#ffffff"
            android:text="@string/rb_male"/>

        <RadioButton
            android:id="@+id/rbFemale"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="#ffffff"
            android:text="@string/rb_female"/>
    </RadioGroup>

    <Button
        android:id="@+id/btSave"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/bt_save"/>

    <ListView
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:background="#ffffff"
        android:entries="@array/dlinkllist"/>
</LinearLayout>

Write the XX part of string.xml in the text element of each view. Then string.xml In addition, regarding layout_width and layout_marginBottom, it decides the layout and shape of the view.

Try to understand intuitively with images.

キャプチャ.PNG

It's just like writing, but it looks like this. RadioGroup describes RadioButton as a child element. When LinearLayout is a parent element, it decides whether to arrange its child elements vertically or horizontally. (Oriental = "vertical" part) There are other roles, but I wonder if this understanding is sufficient for this sample.

At the end

It's pretty simple, but I tried to summarize the view in my own way. It doesn't come together as I expected, but I'm thinking of continuing.

Next time, I will summarize the events and listeners.

Recommended Posts

A newcomer tries to summarize the Android view (beginner Android application development)
Introduction to Android application development
[Introduction to Android application development] Let's make a counter
A memorandum for android application development beginners
I tried to summarize the stumbling points when developing an Android application
Summarize the life cycle of Java objects to be aware of in Android development
Learn while making a WEB server Introduction to WEB application development from the basics
I saw the list view of Android development collectively
Android application development preparation 7/15
How to take a screenshot with the Android Studio emulator
I tried to take a look at the flow of Android development environment construction with Android Studio
[Android] Create a square view while maintaining the aspect ratio: SquareLayout
Install Rails in the development environment and create a new application
Try to introduce OpenCV to Android application
About the basics of Android development
Preparing to create a Rails application
Android Development-Try to display a dialog-
How to "hollow" View on Android
Notes for Android application development beginners
[Kotlin / Android] Create a custom view
I tried to make a simple face recognition Android application using OpenCV
I tried to summarize the key points of gRPC design and development
Java beginner tried to make a simple web application using Spring Boot
I tried to build a Firebase application development environment with Docker in 2020
[Android application development] How to display in full screen (notification bar hidden)
Get the event that the iOS application moves to the back on the View side
Trial and error to display national holidays in Android application development. Part 1
Deploy a Node.js application to an ECS instance using the Cloud Toolkit
Android development, how to check null in the value of JSON object
A simple application (CT) that allows you to view the RDSR in which the radiation exposure dose is recorded.