IEには対応していません。Edgeでサイトを開く ≫

ソースコード source code

下記アプリの主要なソースコードを公開しています。アプリ開発の参考になれば幸いです。

画像等が別途必要ですので下記情報のみでアプリが完成するものではありません。 アプリは少しずつ機能拡張していますのでストア公開されているアプリと内容が異なる場合があります。 コードはコピーして自由にお使いいただけます。ただし著作権は放棄しておりませんので全部の再掲載はご遠慮ください。部分的に再掲載したり、改変して再掲載するのは構いません。 自身のアプリ作成の参考として個人使用・商用問わず自由にお使いいただけます。 コード記述のお手本を示すものではありません。ミニアプリですので変数名などさほど気遣いしていない部分も有りますし間違いも有るかと思いますので参考程度にお考え下さい。 他の賢者の皆様が公開されているコードを参考にした箇所も含まれます。Androidアプリ開発の熟練者が書いたコードではありません。 エンジニア向け技術情報共有サービスではありませんので説明は省いています。ご了承ください。 GitHubなどへの公開は予定しておりません。

下記コードの最終ビルド日: 2021-05-08

build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    ext.kotlin_version = "1.4.32"
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:4.2.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        mavenCentral()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

app/build.gradle

plugins {
    id 'com.android.application'
    id 'kotlin-android'
}

android {
    compileSdkVersion 30
    buildToolsVersion "30.0.3"

    defaultConfig {
        applicationId "jp.aosystem.fortuneslip"
        minSdkVersion 21
        targetSdkVersion 30
        multiDexEnabled true
        versionCode 8
        versionName "1.7"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        vectorDrawables {
            useSupportLibrary true
        }
    }

    buildTypes {
        release {
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = '1.8'
    }
    buildFeatures {
        viewBinding true
    }
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
    implementation 'androidx.core:core-ktx:1.3.2'
    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'com.google.android.material:material:1.3.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
    implementation 'com.google.android.gms:play-services-ads:20.1.0'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}

app/src/main/AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="jp.aosystem.fortuneslip">

    <uses-permission android:name="android.permission.INTERNET" />

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/Theme.FortuneSlip">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name=".SettingActivity" />

        <meta-data
            android:name="com.google.android.gms.ads.APPLICATION_ID"
            android:value="ca-app-pub-0000000000000000~0000000000">
    </application>

</manifest>

app/src/main/java/jp/aosystem/fortuneslip/MainActivity.kt

package jp.aosystem.fortuneslip

import android.app.Activity
import android.content.Context
import android.content.Intent
import android.content.res.Configuration
import android.graphics.Color
import android.os.*
import android.util.DisplayMetrics
import android.view.View
import android.view.ViewTreeObserver.OnGlobalLayoutListener
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.app.AppCompatDelegate
import androidx.constraintlayout.widget.ConstraintLayout
import com.google.android.gms.ads.AdRequest
import com.google.android.gms.ads.AdSize
import com.google.android.gms.ads.AdView
import com.google.android.gms.ads.MobileAds
import jp.aosystem.fortuneslip.databinding.ActivityMainBinding
import java.util.*
import kotlin.random.Random


class MainActivity : AppCompatActivity() {
    private lateinit var binding: ActivityMainBinding
    private lateinit var viewModel: ConstraintLayout
    //
    private val resourceImg: List<Int> = listOf(
            R.drawable.omikuji001,
            R.drawable.omikuji002,
            R.drawable.omikuji003,
            R.drawable.omikuji004,
            R.drawable.omikuji005,
            R.drawable.omikuji006,
            R.drawable.omikuji007,
            R.drawable.omikuji008,
            R.drawable.omikuji009,
            R.drawable.omikuji010,
            R.drawable.omikuji011,
            R.drawable.omikuji012,
            R.drawable.omikuji013,
            R.drawable.omikuji014,
            R.drawable.omikuji015,
            R.drawable.omikuji016,
            R.drawable.omikuji017,
            R.drawable.omikuji018,
            R.drawable.omikuji019,
            R.drawable.omikuji020,
            R.drawable.omikuji021,
            R.drawable.omikuji022,
            R.drawable.omikuji023,
            R.drawable.omikuji024,
            R.drawable.omikuji025,
            R.drawable.omikuji026,
            R.drawable.omikuji027,
            R.drawable.omikuji028,
            R.drawable.omikuji029,
            R.drawable.omikuji030,
            R.drawable.omikuji031,
            R.drawable.omikuji032,
            R.drawable.omikuji033,
            R.drawable.omikuji034,
            R.drawable.omikuji035,
            R.drawable.omikuji036,
            R.drawable.omikuji037,
            R.drawable.omikuji038,
            R.drawable.omikuji039,
            R.drawable.omikuji040,
            R.drawable.omikuji041,
            R.drawable.omikuji042,
            R.drawable.omikuji043,
            R.drawable.omikuji044,
            R.drawable.omikuji045,
            R.drawable.omikuji046,
            R.drawable.omikuji047,
            R.drawable.omikuji048,
            R.drawable.omikuji049,
            R.drawable.omikuji050,
            R.drawable.omikuji051,
            R.drawable.omikuji052,
            R.drawable.omikuji053,
            R.drawable.omikuji054,
            R.drawable.omikuji055,
            R.drawable.omikuji056,
            R.drawable.omikuji057,
            R.drawable.omikuji058,
            R.drawable.omikuji059,
            R.drawable.omikuji060,
            R.drawable.omikuji061,
            R.drawable.omikuji062,
            R.drawable.omikuji063,
            R.drawable.omikuji064,
            R.drawable.omikuji065,
            R.drawable.omikuji066,
            R.drawable.omikuji067,
            R.drawable.omikuji068,
            R.drawable.omikuji069,
            R.drawable.omikuji070,
            R.drawable.omikuji071,
            R.drawable.omikuji072,
            R.drawable.omikuji073,
            R.drawable.omikuji074,
            R.drawable.omikuji075,
            R.drawable.omikuji076,
            R.drawable.omikuji077,
            R.drawable.omikuji078,
            R.drawable.omikuji079,
            R.drawable.omikuji080,
            R.drawable.omikuji081,
            R.drawable.omikuji082,
            R.drawable.omikuji083,
            R.drawable.omikuji084,
            R.drawable.omikuji085,
            R.drawable.omikuji086,
            R.drawable.omikuji087,
            R.drawable.omikuji088,
            R.drawable.omikuji089,
            R.drawable.omikuji090,
            R.drawable.omikuji091,
            R.drawable.omikuji092,
            R.drawable.omikuji093,
            R.drawable.omikuji094,
            R.drawable.omikuji095,
            R.drawable.omikuji096,
            R.drawable.omikuji097,
            R.drawable.omikuji098,
            R.drawable.omikuji099,
            R.drawable.omikuji100,
            R.drawable.omikuji101,
            R.drawable.omikuji102,
            R.drawable.omikuji103,
            R.drawable.omikuji104,
            R.drawable.omikuji105,
            R.drawable.omikuji106,
            R.drawable.omikuji107,
            R.drawable.omikuji108,
            R.drawable.omikuji109,
            R.drawable.omikuji110,
            R.drawable.omikuji111,
            R.drawable.omikuji112,
            R.drawable.omikuji113,
            R.drawable.omikuji114,
            R.drawable.omikuji115,
            R.drawable.omikuji116,
            R.drawable.omikuji117,
            R.drawable.omikuji118,
            R.drawable.omikuji119,
            R.drawable.omikuji120,
    )
    private val textPositions: List<Triple<Int, Int, Int>> = listOf(
            //time,x,y
            Triple(84, 547, 440),
            Triple(85, 549, 444),
            Triple(86, 550, 450),
            Triple(87, 550, 454),
            Triple(88, 552, 459),
            Triple(89, 554, 464),
            Triple(90, 555, 469),
            Triple(91, 556, 474),
            Triple(92, 558, 479),
            Triple(93, 560, 484),
            Triple(94, 562, 489),
            Triple(95, 563, 495),
            Triple(96, 565, 500),
            Triple(97, 567, 505),
            Triple(98, 569, 511),
            Triple(99, 571, 516),
            Triple(100, 573, 522),
            Triple(101, 575, 530),
            Triple(102, 578, 539),
            Triple(103, 580, 550),
            Triple(104, 583, 563),
            Triple(105, 587, 576),
            Triple(106, 590, 592),
            Triple(107, 594, 608),
            Triple(108, 599, 626),
            Triple(109, 604, 645),
            Triple(110, 608, 665),
            Triple(111, 614, 687),
            Triple(112, 619, 708),
            Triple(113, 625, 730),
            Triple(114, 630, 751),
            Triple(115, 636, 772),
            Triple(116, 641, 792),
            Triple(117, 646, 808),
            Triple(118, 651, 822),
            Triple(119, 654, 832),
    )
    data class ItemState(
            var name: String,
            var ratio: Int,
    )
    private lateinit var textResult: TextView
    private var baseWidth: Int = 0
    private var baseHeight: Int = 0
    private var boxSize: Int = 0
    private var marginLeft: Int = 0
    private var marginTop: Int = 0
    private var actionCount: Int = 0    //回転の制御
    private var destroyFlag: Boolean = false    //Activity破棄された場合など
    private var busyFlag: Boolean = false       //回転中
    private var itemStates: Array<ItemState> = arrayOf()
    private var choiceFortune = 0
    private var animationSpeed: Int = 10
    private var themeNumber: Int = 0
    private var localeLanguage: String = ""

    //adMob
    private lateinit var adView: AdView     //adMob
    private val adSize: AdSize
        get() {
            val display = windowManager.defaultDisplay
            val outMetrics = DisplayMetrics()
            display.getMetrics(outMetrics)
            val density = outMetrics.density
            var adWidthPixels = this.binding.adContainer.width.toFloat()
            if (adWidthPixels == 0f) {
                adWidthPixels = outMetrics.widthPixels.toFloat()
            }
            val adWidth = (adWidthPixels / density).toInt()
            return AdSize.getCurrentOrientationAnchoredAdaptiveBannerAdSize(this, adWidth)
        }

    companion object {
        //private const val AD_UNIT_ID: String = "ca-app-pub-3940256099942544/6300978111"     //adMob Test
        private const val AD_UNIT_ID: String = "ca-app-pub-0000000000000000/0000000000"     //adMob
        private const val RESULT_SETTING_ACTIVITY: Int = 1
        internal const val SETTINGS: String = "settings"
        internal const val ANIMATION_SPEED: String = "animationSpeed"
        internal const val THEME_NUMBER: String = "themeNumber"
        internal const val LOCALE_LANGUAGE: String = "localeLanguage"
        internal const val ITEM_NAME1: String = "itemName1"
        internal const val ITEM_NAME2: String = "itemName2"
        internal const val ITEM_NAME3: String = "itemName3"
        internal const val ITEM_NAME4: String = "itemName4"
        internal const val ITEM_NAME5: String = "itemName5"
        internal const val ITEM_NAME6: String = "itemName6"
        internal const val ITEM_NAME7: String = "itemName7"
        internal const val ITEM_RATIO1: String = "itemRatio1"
        internal const val ITEM_RATIO2: String = "itemRatio2"
        internal const val ITEM_RATIO3: String = "itemRatio3"
        internal const val ITEM_RATIO4: String = "itemRatio4"
        internal const val ITEM_RATIO5: String = "itemRatio5"
        internal const val ITEM_RATIO6: String = "itemRatio6"
        internal const val ITEM_RATIO7: String = "itemRatio7"
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        //setContentView(R.layout.activity_main)
        this.binding = ActivityMainBinding.inflate(layoutInflater)
        this.viewModel = this.binding.root
        setContentView(this.viewModel)
        //タイトルバー非表示
        supportActionBar?.hide()
        //テーマ読み込みと設定
        this.loadThemeNumber()
        this.setTheme()
        //設定読み出し
        this.loadItemStates()
        this.loadSpeed()
        //adMob
        MobileAds.initialize(this) {}
        this.adView = AdView(this)
        this.binding.adContainer.addView(this.adView)
        this.loadBanner()
    }

    override fun onResume() {
        super.onResume()
        //準備が出来たらwidth,heightを取得して次へ進む
        this.binding.layoutBase.viewTreeObserver.addOnGlobalLayoutListener(object : OnGlobalLayoutListener {
            override fun onGlobalLayout() {
                this@MainActivity.binding.layoutBase.viewTreeObserver.removeOnGlobalLayoutListener(this)
                this@MainActivity.baseWidth = this@MainActivity.binding.layoutBase.width
                this@MainActivity.baseHeight = this@MainActivity.binding.layoutBase.height
                this@MainActivity.initKuji()
            }
        })
    }

    override fun onDestroy() {
        this.destroyFlag = true
        super.onDestroy()
    }

    //adMob
    private fun loadBanner() {
        this.adView.adUnitId = AD_UNIT_ID
        this.adView.adSize = adSize
        val adRequest = AdRequest
            .Builder()
            //.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
            .build()
        this.adView.loadAd(adRequest)
    }

    private fun initKuji() {
        if (::textResult.isInitialized) {
            this.binding.layoutBase.removeView(this.textResult)
        }
        this.boxSize = minOf(this.baseWidth, this.baseHeight)
        this.marginLeft = (this.baseWidth - this.boxSize).div(2)
        this.marginTop = (this.baseHeight - this.boxSize).div(2)
        //text
        this.textResult = TextView(this)
        this.textResult.text = ""
        this.textResult.textSize = 16F
        this.textResult.setTextColor(Color.rgb(255,255,255))
        this.textResult.alpha = 0F
        this.binding.layoutBase.addView(this.textResult)
        //
        this.startButtonColor(true)
    }

    fun onClickStart(v: View) {
        if (this.busyFlag) {
            return
        }
        this.busyFlag = true
        this.textResult.alpha = 0F
        this.startButtonColor(false)
        //fortuneを選ぶ
        var ratioSum: Int = 0
        this.itemStates.forEach {
            ratioSum += it.ratio
        }
        if (ratioSum == 0) {    //選ぶものが無くなった
            this.textResult.text = resources.getString(R.string.empty)
            this.textResult.x = 50F
            this.textResult.y = 40F
            this.textResult.alpha = 1F
            this.busyFlag = false
            return
        }
        var remainNum: Int = Random.nextInt(ratioSum)
        var choiceRank: Int = 0
        for (i in this.itemStates.indices) {
            if (this.itemStates[i].ratio != 0) {
                remainNum -= this.itemStates[i].ratio
                if (remainNum < 0) {
                    choiceRank = i     //このランクに決定
                    break
                }
            }
        }
        //
        this.choiceFortune = choiceRank
        this.destroyFlag = false
        this.actionCount = 0
        this.textResult.text = this.itemStates[this.choiceFortune].name
        this.actionTimeline()
    }

    private fun actionTimeline() {
        Handler(Looper.getMainLooper()).postDelayed({
            if (this.destroyFlag) {
                this.startButtonColor(true)
                return@postDelayed
            }
            this.binding.imageKuji.setImageResource(resourceImg[this.actionCount])   //クジ画像切り替え
            this.visibleFortune(this.actionCount) //結果表示
            this.actionCount += 1
            if (this.actionCount > 119) {
                if (this.destroyFlag) {
                    this.startButtonColor(true)
                    return@postDelayed
                }
                this.binding.imageKuji.setImageResource(resourceImg[119])  //クジ最後
                this.busyFlag = false
                this.startButtonColor(true)
                return@postDelayed
            }
            actionTimeline()
        }, this.animationSpeed.toLong())
    }

    private fun visibleFortune(num: Int) {
        if (num < 84) {
            return
        }
        for (i in this.textPositions.indices) {
            val (t, x, y) = this.textPositions[i]
            if (t == num) {
                val boxPixel: Float = this.boxSize.div(900F)
                this.textResult.x = this.marginLeft + boxPixel.times(x) - boxPixel.times((num - 84) + 36F)
                this.textResult.y = this.marginTop + boxPixel.times(y) - boxPixel.times((num - 84).times(1.3F) + 24F)
                this.textResult.textSize = (num - 84F).div(119F - 84F).times(14F) + 4F
                break
            }
        }
        if (num == 84) {
            this.textResult.alpha = 1F
        }
    }

    private fun startButtonColor(onOff: Boolean) {
        if (onOff) {
            this.binding.textStart.alpha = 1F
            this.binding.textSetting.alpha = 1F
        } else {
            this.binding.textStart.alpha = 0F
            this.binding.textSetting.alpha = 0F
        }
    }

    //-------------------------------------------------

    fun onClickSetting(v: View) {
        if (this.busyFlag) {
            return
        }
        this.destroyFlag = true
        val intent = Intent(applicationContext, SettingActivity::class.java)
        intent.putExtra(ITEM_NAME1, this.itemStates[0].name)
        intent.putExtra(ITEM_RATIO1, this.itemStates[0].ratio)
        intent.putExtra(ITEM_NAME2, this.itemStates[1].name)
        intent.putExtra(ITEM_RATIO2, this.itemStates[1].ratio)
        intent.putExtra(ITEM_NAME3, this.itemStates[2].name)
        intent.putExtra(ITEM_RATIO3, this.itemStates[2].ratio)
        intent.putExtra(ITEM_NAME4, this.itemStates[3].name)
        intent.putExtra(ITEM_RATIO4, this.itemStates[3].ratio)
        intent.putExtra(ITEM_NAME5, this.itemStates[4].name)
        intent.putExtra(ITEM_RATIO5, this.itemStates[4].ratio)
        intent.putExtra(ITEM_NAME6, this.itemStates[5].name)
        intent.putExtra(ITEM_RATIO6, this.itemStates[5].ratio)
        intent.putExtra(ITEM_NAME7, this.itemStates[6].name)
        intent.putExtra(ITEM_RATIO7, this.itemStates[6].ratio)
        intent.putExtra(ANIMATION_SPEED, this.animationSpeed)
        intent.putExtra(THEME_NUMBER, this.themeNumber)
        intent.putExtra(LOCALE_LANGUAGE, this.localeLanguage)
        startActivityForResult(intent, RESULT_SETTING_ACTIVITY)
    }

    override fun onActivityResult(requestCode: Int, resultCode: Int, intent: Intent?) {
        super.onActivityResult(requestCode, resultCode, intent)
        if (resultCode == Activity.RESULT_OK && requestCode == RESULT_SETTING_ACTIVITY && intent != null) {
            val itemName1: String = intent.getStringExtra(ITEM_NAME1) ?: ""
            val itemRatio1: Int = intent.getIntExtra(ITEM_RATIO1, 0)
            val itemName2: String = intent.getStringExtra(ITEM_NAME2) ?: ""
            val itemRatio2: Int = intent.getIntExtra(ITEM_RATIO2, 0)
            val itemName3: String = intent.getStringExtra(ITEM_NAME3) ?: ""
            val itemRatio3: Int = intent.getIntExtra(ITEM_RATIO3, 0)
            val itemName4: String = intent.getStringExtra(ITEM_NAME4) ?: ""
            val itemRatio4: Int = intent.getIntExtra(ITEM_RATIO4, 0)
            val itemName5: String = intent.getStringExtra(ITEM_NAME5) ?: ""
            val itemRatio5: Int = intent.getIntExtra(ITEM_RATIO5, 0)
            val itemName6: String = intent.getStringExtra(ITEM_NAME6) ?: ""
            val itemRatio6: Int = intent.getIntExtra(ITEM_RATIO6, 0)
            val itemName7: String = intent.getStringExtra(ITEM_NAME7) ?: ""
            val itemRatio7: Int = intent.getIntExtra(ITEM_RATIO7, 0)
            this.itemStates = arrayOf(
                    ItemState(itemName1, itemRatio1),
                    ItemState(itemName2, itemRatio2),
                    ItemState(itemName3, itemRatio3),
                    ItemState(itemName4, itemRatio4),
                    ItemState(itemName5, itemRatio5),
                    ItemState(itemName6, itemRatio6),
                    ItemState(itemName7, itemRatio7),
            )
            this.saveItemStates()
            //
            val lastSpeed = this.animationSpeed
            this.animationSpeed = intent.getIntExtra(ANIMATION_SPEED, 10)
            if (lastSpeed != this.animationSpeed) {
                if (this.animationSpeed <= 0) {
                    this.animationSpeed = 1
                } else if (this.animationSpeed > 1000) {
                    this.animationSpeed = 1000
                }
                this.saveSpeed()
            }
            //
            val lastThemeNumber: Int = this.themeNumber
            this.themeNumber = intent.getIntExtra(THEME_NUMBER, 0)
            if (lastThemeNumber != this.themeNumber) {
                this.saveThemeNumber()
            }
            //
            val lastLocaleLanguage = this.localeLanguage
            this.localeLanguage = intent.getStringExtra(LOCALE_LANGUAGE) ?: ""
            if (this.localeLanguage != lastLocaleLanguage) {
                this.saveLocaleLanguage()
            }
        }
        //再構築しないと位置がずれる
        //SettingActivityからMainActivityに戻る時に言語を変更するとクラッシュするので再構築する
        recreate()
    }

    //-------------------------------------------------

    //itemsを保存
    private fun saveItemStates() {
        getSharedPreferences(SETTINGS, Context.MODE_PRIVATE).edit().apply {
            putString(ITEM_NAME1, this@MainActivity.itemStates[0].name)
            putInt(ITEM_RATIO1, this@MainActivity.itemStates[0].ratio)
            putString(ITEM_NAME2, this@MainActivity.itemStates[1].name)
            putInt(ITEM_RATIO2, this@MainActivity.itemStates[1].ratio)
            putString(ITEM_NAME3, this@MainActivity.itemStates[2].name)
            putInt(ITEM_RATIO3, this@MainActivity.itemStates[2].ratio)
            putString(ITEM_NAME4, this@MainActivity.itemStates[3].name)
            putInt(ITEM_RATIO4, this@MainActivity.itemStates[3].ratio)
            putString(ITEM_NAME5, this@MainActivity.itemStates[4].name)
            putInt(ITEM_RATIO5, this@MainActivity.itemStates[4].ratio)
            putString(ITEM_NAME6, this@MainActivity.itemStates[5].name)
            putInt(ITEM_RATIO6, this@MainActivity.itemStates[5].ratio)
            putString(ITEM_NAME7, this@MainActivity.itemStates[6].name)
            putInt(ITEM_RATIO7, this@MainActivity.itemStates[6].ratio)
            apply()
        }
    }

    //itemsを読み出し
    private fun loadItemStates() {
        val pref = getSharedPreferences(SETTINGS, Context.MODE_PRIVATE)
        this.itemStates = arrayOf(
                ItemState(pref.getString(ITEM_NAME1, "") ?: "", pref.getInt(ITEM_RATIO1, 0)),
                ItemState(pref.getString(ITEM_NAME2, "") ?: "", pref.getInt(ITEM_RATIO2, 0)),
                ItemState(pref.getString(ITEM_NAME3, "") ?: "", pref.getInt(ITEM_RATIO3, 0)),
                ItemState(pref.getString(ITEM_NAME4, "") ?: "", pref.getInt(ITEM_RATIO4, 0)),
                ItemState(pref.getString(ITEM_NAME5, "") ?: "", pref.getInt(ITEM_RATIO5, 0)),
                ItemState(pref.getString(ITEM_NAME6, "") ?: "", pref.getInt(ITEM_RATIO6, 0)),
                ItemState(pref.getString(ITEM_NAME7, "") ?: "", pref.getInt(ITEM_RATIO7, 0)),
        )
        var emptyFlag: Boolean = true
        for (i in this.itemStates.indices) {
            if (this.itemStates[i].name != "") {
                emptyFlag = false
                break
            }
        }
        if (emptyFlag) {
            this.itemStates[0].name = resources.getString(R.string.rank1)
            this.itemStates[0].ratio = 1
            this.itemStates[1].name = resources.getString(R.string.rank2)
            this.itemStates[1].ratio = 3
            this.itemStates[2].name = resources.getString(R.string.rank3)
            this.itemStates[2].ratio = 5
            this.itemStates[3].name = resources.getString(R.string.rank4)
            this.itemStates[3].ratio = 5
            this.itemStates[4].name = resources.getString(R.string.rank5)
            this.itemStates[4].ratio = 5
            this.itemStates[5].name = resources.getString(R.string.rank6)
            this.itemStates[5].ratio = 1
            this.itemStates[6].name = resources.getString(R.string.rank7)
            this.itemStates[6].ratio = 1
        }
    }

    //-------------------------------------------------

    //animationSpeedを保存
    private fun saveSpeed() {
        getSharedPreferences(SETTINGS, Context.MODE_PRIVATE).edit().apply {
            putInt(ANIMATION_SPEED, this@MainActivity.animationSpeed)
            apply()
        }
    }

    //animationSpeedを読み出し
    private fun loadSpeed() {
        val pref = getSharedPreferences(SETTINGS, Context.MODE_PRIVATE)
        this.animationSpeed = pref.getInt(ANIMATION_SPEED, 10)
        if (this.animationSpeed <= 0) {
            this.animationSpeed = 1
        } else if (this.animationSpeed > 1000) {
            this.animationSpeed = 1000
        }
    }

    //-------------------------------------------------

    //テーマを保存
    private fun saveThemeNumber() {
        getSharedPreferences(SETTINGS, Context.MODE_PRIVATE).edit().apply {
            putInt(THEME_NUMBER, this@MainActivity.themeNumber)
            apply()
        }
    }

    //テーマを読み出し
    private fun loadThemeNumber() {
        val pref = getSharedPreferences(SETTINGS, Context.MODE_PRIVATE)
        this.themeNumber = pref.getInt(THEME_NUMBER, 0)
    }

    //テーマを設定
    private fun setTheme() {
        when (this.themeNumber) {
            0 -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO)
            1 -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES)
        }
    }

    //----------------------------------------------

    //localeLanguageを保存
    private fun saveLocaleLanguage() {
        getSharedPreferences(SETTINGS, Context.MODE_PRIVATE).edit().apply {
            putString(LOCALE_LANGUAGE, this@MainActivity.localeLanguage)
            apply()
        }
    }

    //言語設定
    override fun attachBaseContext(base: Context) {
        val pref = base.getSharedPreferences(SETTINGS, Context.MODE_PRIVATE)
        this.localeLanguage = pref.getString(LOCALE_LANGUAGE, "") ?: ""
        val loc: Locale? = if (this.localeLanguage != "") Locale(this.localeLanguage) else null
        if (loc != null) {
            val res = base.resources
            val config = Configuration(res.configuration)
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {    //minSdkVersion 24
                val localeList = LocaleList(loc)
                LocaleList.setDefault(localeList)
                config.setLocales(localeList)
            } else {    //minSdkVersion 17  16はダメ
                config.setLocale(loc)
            }
            super.attachBaseContext(base.createConfigurationContext(config))
        } else {
            super.attachBaseContext(base)
        }
    }

    //----------------------------------------------

}

app/src/main/java/jp/aosystem/fortuneslip/SettingActivity.kt

package jp.aosystem.fortuneslip

import android.app.Activity
import android.content.Context
import android.content.Intent
import android.content.res.Configuration
import android.os.Build
import android.os.Bundle
import android.os.LocaleList
import android.view.View
import android.view.inputmethod.InputMethodManager
import androidx.appcompat.app.AppCompatActivity
import androidx.constraintlayout.widget.ConstraintLayout
import jp.aosystem.fortuneslip.databinding.ActivitySettingBinding
import java.util.*

class SettingActivity : AppCompatActivity() {
    private lateinit var binding: ActivitySettingBinding
    private lateinit var viewModel: ConstraintLayout
    private var inputMethodManager: InputMethodManager? = null

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        //setContentView(R.layout.activity_main)
        this.binding = ActivitySettingBinding.inflate(layoutInflater)
        this.viewModel = this.binding.root
        setContentView(this.viewModel)
        //データ受け取り
        val intent = this.intent
        val itemName1: String = intent.getStringExtra(MainActivity.ITEM_NAME1) ?: ""
        val itemRatio1: Int = intent.getIntExtra(MainActivity.ITEM_RATIO1,0)
        val itemName2: String = intent.getStringExtra(MainActivity.ITEM_NAME2) ?: ""
        val itemRatio2: Int = intent.getIntExtra(MainActivity.ITEM_RATIO2,0)
        val itemName3: String = intent.getStringExtra(MainActivity.ITEM_NAME3) ?: ""
        val itemRatio3: Int = intent.getIntExtra(MainActivity.ITEM_RATIO3,0)
        val itemName4: String = intent.getStringExtra(MainActivity.ITEM_NAME4) ?: ""
        val itemRatio4: Int = intent.getIntExtra(MainActivity.ITEM_RATIO4,0)
        val itemName5: String = intent.getStringExtra(MainActivity.ITEM_NAME5) ?: ""
        val itemRatio5: Int = intent.getIntExtra(MainActivity.ITEM_RATIO5,0)
        val itemName6: String = intent.getStringExtra(MainActivity.ITEM_NAME6) ?: ""
        val itemRatio6: Int = intent.getIntExtra(MainActivity.ITEM_RATIO6,0)
        val itemName7: String = intent.getStringExtra(MainActivity.ITEM_NAME7) ?: ""
        val itemRatio7: Int = intent.getIntExtra(MainActivity.ITEM_RATIO7,0)
        val animationSpeed: Int = intent.getIntExtra(MainActivity.ANIMATION_SPEED,10)
        val themeNumber: Int = intent.getIntExtra(MainActivity.THEME_NUMBER,0)
        if (itemName1 != "") {
            this.binding.editName1.setText(itemName1)
        }
        if (itemRatio1 != 0) {
            this.binding.editRatio1.setText(itemRatio1.toString())
        }
        this.binding.editName2.setText(itemName2)
        if (itemRatio2 != 0) {
            this.binding.editRatio2.setText(itemRatio2.toString())
        }
        this.binding.editName3.setText(itemName3)
        if (itemRatio3 != 0) {
            this.binding.editRatio3.setText(itemRatio3.toString())
        }
        this.binding.editName4.setText(itemName4)
        if (itemRatio4 != 0) {
            this.binding.editRatio4.setText(itemRatio4.toString())
        }
        this.binding.editName5.setText(itemName5)
        if (itemRatio5 != 0) {
            this.binding.editRatio5.setText(itemRatio5.toString())
        }
        this.binding.editName6.setText(itemName6)
        if (itemRatio6 != 0) {
            this.binding.editRatio6.setText(itemRatio6.toString())
        }
        this.binding.editName7.setText(itemName7)
        if (itemRatio7 != 0) {
            this.binding.editRatio7.setText(itemRatio7.toString())
        }
        this.binding.editSpeed.setText(animationSpeed.toString())
        this.binding.switchTheme.isChecked = themeNumber != 0
        val localeLanguage: String = intent.getStringExtra(MainActivity.LOCALE_LANGUAGE) ?: ""
        when (localeLanguage) {
            "en" -> this.binding.radioLanguageEn.isChecked = true
            "ja" -> this.binding.radioLanguageJa.isChecked = true
            else -> this.binding.radioLanguageSystem.isChecked = true
        }
        //
        supportActionBar?.hide()    //タイトルバー非表示
        //
        this.setTouchListener()
    }

    //背景タッチでテキストエリアからフォーカスを外してキーボードを隠す
    private fun setTouchListener() {
        this.inputMethodManager = getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager?
        this.binding.editName1.setOnFocusChangeListener { _, hasFocus ->
            if (!hasFocus) {
                this.inputMethodManager!!.hideSoftInputFromWindow(   //キーボードを隠す
                        this.binding.editName1.windowToken,
                        InputMethodManager.HIDE_NOT_ALWAYS
                )
            }
        }
        this.binding.editRatio1.setOnFocusChangeListener { _, hasFocus ->
            if (!hasFocus) {
                this.inputMethodManager!!.hideSoftInputFromWindow(   //キーボードを隠す
                        this.binding.editRatio1.windowToken,
                        InputMethodManager.HIDE_NOT_ALWAYS
                )
            }
        }
        this.binding.editName2.setOnFocusChangeListener { _, hasFocus ->
            if (!hasFocus) {
                this.inputMethodManager!!.hideSoftInputFromWindow(   //キーボードを隠す
                        this.binding.editName2.windowToken,
                        InputMethodManager.HIDE_NOT_ALWAYS
                )
            }
        }
        this.binding.editRatio2.setOnFocusChangeListener { _, hasFocus ->
            if (!hasFocus) {
                this.inputMethodManager!!.hideSoftInputFromWindow(   //キーボードを隠す
                        this.binding.editRatio2.windowToken,
                        InputMethodManager.HIDE_NOT_ALWAYS
                )
            }
        }
        this.binding.editName3.setOnFocusChangeListener { _, hasFocus ->
            if (!hasFocus) {
                this.inputMethodManager!!.hideSoftInputFromWindow(   //キーボードを隠す
                        this.binding.editName3.windowToken,
                        InputMethodManager.HIDE_NOT_ALWAYS
                )
            }
        }
        this.binding.editRatio3.setOnFocusChangeListener { _, hasFocus ->
            if (!hasFocus) {
                this.inputMethodManager!!.hideSoftInputFromWindow(   //キーボードを隠す
                        this.binding.editRatio3.windowToken,
                        InputMethodManager.HIDE_NOT_ALWAYS
                )
            }
        }
        this.binding.editName4.setOnFocusChangeListener { _, hasFocus ->
            if (!hasFocus) {
                this.inputMethodManager!!.hideSoftInputFromWindow(   //キーボードを隠す
                        this.binding.editName4.windowToken,
                        InputMethodManager.HIDE_NOT_ALWAYS
                )
            }
        }
        this.binding.editRatio4.setOnFocusChangeListener { _, hasFocus ->
            if (!hasFocus) {
                this.inputMethodManager!!.hideSoftInputFromWindow(   //キーボードを隠す
                        this.binding.editRatio4.windowToken,
                        InputMethodManager.HIDE_NOT_ALWAYS
                )
            }
        }
        this.binding.editName5.setOnFocusChangeListener { _, hasFocus ->
            if (!hasFocus) {
                this.inputMethodManager!!.hideSoftInputFromWindow(   //キーボードを隠す
                        this.binding.editName5.windowToken,
                        InputMethodManager.HIDE_NOT_ALWAYS
                )
            }
        }
        this.binding.editRatio5.setOnFocusChangeListener { _, hasFocus ->
            if (!hasFocus) {
                this.inputMethodManager!!.hideSoftInputFromWindow(   //キーボードを隠す
                        this.binding.editRatio5.windowToken,
                        InputMethodManager.HIDE_NOT_ALWAYS
                )
            }
        }
        this.binding.editName6.setOnFocusChangeListener { _, hasFocus ->
            if (!hasFocus) {
                this.inputMethodManager!!.hideSoftInputFromWindow(   //キーボードを隠す
                        this.binding.editName6.windowToken,
                        InputMethodManager.HIDE_NOT_ALWAYS
                )
            }
        }
        this.binding.editRatio6.setOnFocusChangeListener { _, hasFocus ->
            if (!hasFocus) {
                this.inputMethodManager!!.hideSoftInputFromWindow(   //キーボードを隠す
                        this.binding.editRatio6.windowToken,
                        InputMethodManager.HIDE_NOT_ALWAYS
                )
            }
        }
        this.binding.editName7.setOnFocusChangeListener { _, hasFocus ->
            if (!hasFocus) {
                this.inputMethodManager!!.hideSoftInputFromWindow(   //キーボードを隠す
                        this.binding.editName7.windowToken,
                        InputMethodManager.HIDE_NOT_ALWAYS
                )
            }
        }
        this.binding.editRatio7.setOnFocusChangeListener { _, hasFocus ->
            if (!hasFocus) {
                this.inputMethodManager!!.hideSoftInputFromWindow(   //キーボードを隠す
                        this.binding.editRatio7.windowToken,
                        InputMethodManager.HIDE_NOT_ALWAYS
                )
            }
        }
        this.binding.editSpeed.setOnFocusChangeListener { _, hasFocus ->
            if (!hasFocus) {
                this.inputMethodManager!!.hideSoftInputFromWindow(   //キーボードを隠す
                        this.binding.editSpeed.windowToken,
                        InputMethodManager.HIDE_NOT_ALWAYS
                )
            }
        }
    }

    fun onClickApply(v: View) {
        val itemName1: String = this.binding.editName1.text.toString()
        val itemRatio1: Int = ("0" + this.binding.editRatio1.text.toString()).toInt()
        val itemName2: String = this.binding.editName2.text.toString()
        val itemRatio2: Int = ("0" + this.binding.editRatio2.text.toString()).toInt()
        val itemName3: String = this.binding.editName3.text.toString()
        val itemRatio3: Int = ("0" + this.binding.editRatio3.text.toString()).toInt()
        val itemName4: String = this.binding.editName4.text.toString()
        val itemRatio4: Int = ("0" + this.binding.editRatio4.text.toString()).toInt()
        val itemName5: String = this.binding.editName5.text.toString()
        val itemRatio5: Int = ("0" + this.binding.editRatio5.text.toString()).toInt()
        val itemName6: String = this.binding.editName6.text.toString()
        val itemRatio6: Int = ("0" + this.binding.editRatio6.text.toString()).toInt()
        val itemName7: String = this.binding.editName7.text.toString()
        val itemRatio7: Int = ("0" + this.binding.editRatio7.text.toString()).toInt()
        val animationSpeed: Int = ("0" + this.binding.editSpeed.text.toString()).toInt()
        val themeNumber = if (this.binding.switchTheme.isChecked) 1 else 0
        var localeLanguage: String = ""
        if (this.binding.radioLanguageEn.isChecked) {
            localeLanguage = "en"
        } else if (this.binding.radioLanguageJa.isChecked) {
            localeLanguage = "ja"
        }
        val intent = Intent()
        intent.putExtra(MainActivity.ITEM_NAME1, itemName1)
        intent.putExtra(MainActivity.ITEM_RATIO1, itemRatio1)
        intent.putExtra(MainActivity.ITEM_NAME2, itemName2)
        intent.putExtra(MainActivity.ITEM_RATIO2, itemRatio2)
        intent.putExtra(MainActivity.ITEM_NAME3, itemName3)
        intent.putExtra(MainActivity.ITEM_RATIO3, itemRatio3)
        intent.putExtra(MainActivity.ITEM_NAME4, itemName4)
        intent.putExtra(MainActivity.ITEM_RATIO4, itemRatio4)
        intent.putExtra(MainActivity.ITEM_NAME5, itemName5)
        intent.putExtra(MainActivity.ITEM_RATIO5, itemRatio5)
        intent.putExtra(MainActivity.ITEM_NAME6, itemName6)
        intent.putExtra(MainActivity.ITEM_RATIO6, itemRatio6)
        intent.putExtra(MainActivity.ITEM_NAME7, itemName7)
        intent.putExtra(MainActivity.ITEM_RATIO7, itemRatio7)
        intent.putExtra(MainActivity.ANIMATION_SPEED, animationSpeed)
        intent.putExtra(MainActivity.THEME_NUMBER, themeNumber)
        intent.putExtra(MainActivity.LOCALE_LANGUAGE, localeLanguage)
        setResult(Activity.RESULT_OK, intent)
        finish()
    }

    fun onClickCancel(v: View) {
        val intent = Intent()
        setResult(Activity.RESULT_CANCELED, intent)
        finish()
    }

    //------------------------------------------------------

    //言語設定
    override fun attachBaseContext(base: Context) {
        val pref = base.getSharedPreferences(MainActivity.SETTINGS, Context.MODE_PRIVATE)
        val localeLanguage: String = pref.getString(MainActivity.LOCALE_LANGUAGE, "") ?: ""
        val loc: Locale? = if (localeLanguage != "") Locale(localeLanguage) else null
        if (loc != null) {
            val res = base.resources
            val config = Configuration(res.configuration)
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {    //minSdkVersion 24
                val localeList = LocaleList(loc)
                LocaleList.setDefault(localeList)
                config.setLocales(localeList)
            } else {    //minSdkVersion 17  16はダメ
                config.setLocale(loc)
            }
            super.attachBaseContext(base.createConfigurationContext(config))
        } else {
            super.attachBaseContext(base)
        }
    }

    //---------------------------------------------------------

}

app/src/main/res/layout/activity_main.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"
    tools:context=".MainActivity">


    <LinearLayout
        android:id="@+id/layoutBackground"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:background="#ff0000"
        android:orientation="vertical"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent">

        <LinearLayout
            android:id="@+id/layoutHeader"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="1dp"
            android:orientation="horizontal">

            <TextView
                android:id="@+id/textStart"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="7"
                android:background="#FFC107"
                android:gravity="center"
                android:minHeight="96dp"
                android:onClick="onClickStart"
                android:text="@string/fortuneTelling" />

            <TextView
                android:id="@+id/textSetting"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginStart="1dp"
                android:layout_weight="1"
                android:background="#FF9800"
                android:gravity="center"
                android:minHeight="96dp"
                android:onClick="onClickSetting"
                android:text="@string/setting" />

        </LinearLayout>

        <Space
            android:layout_width="match_parent"
            android:layout_height="5dp" />

        <FrameLayout
            android:id="@+id/layoutBase"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:orientation="vertical">

            <ImageView
                android:id="@+id/imageKuji"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center|center_horizontal|center_vertical"
                android:contentDescription="@string/app_name"
                app:srcCompat="@drawable/omikuji001" />

        </FrameLayout>

        <Space
            android:layout_width="match_parent"
            android:layout_height="80dp" />

    </LinearLayout>

    <LinearLayout
        android:id="@+id/ad_container"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        app:layout_constraintBottom_toBottomOf="parent" />



</androidx.constraintlayout.widget.ConstraintLayout>

app/src/main/res/layout/activity_setting.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"
    tools:context=".SettingActivity">

    <LinearLayout
        android:id="@+id/layoutButtons"
        android:layout_width="match_parent"
        android:layout_height="48dp"
        android:layout_marginTop="1dp"
        android:orientation="horizontal"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent">

        <TextView
            android:id="@+id/textCancel"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="6"
            android:background="#86C663"
            android:gravity="center"
            android:minHeight="48dp"
            android:onClick="onClickCancel"
            android:text="@string/cancel" />

        <TextView
            android:id="@+id/textVerification"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginStart="1dp"
            android:layout_weight="6"
            android:background="#5DC674"
            android:gravity="center"
            android:minHeight="48dp"
            android:onClick="onClickApply"
            android:text="@string/apply" />

    </LinearLayout>
    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/layoutButtons">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:clickable="true"
            android:focusable="true"
            android:focusableInTouchMode="true"
            android:orientation="vertical"
            android:paddingLeft="20dp"
            android:paddingTop="20dp"
            android:paddingRight="20dp"
            android:paddingBottom="50dp">


            <TableLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="20dp">

                <TableRow
                    android:layout_width="match_parent"
                    android:layout_height="match_parent">

                    <TextView
                        android:id="@+id/textName1"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="@string/fortune" />

                    <EditText
                        android:id="@+id/editName1"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="5dp"
                        android:layout_weight="1"
                        android:ems="10"
                        android:inputType="text"
                        tools:ignore="Autofill" />

                    <TextView
                        android:id="@+id/textRatio1"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="20dp"
                        android:text="@string/ratio" />

                    <EditText
                        android:id="@+id/editRatio1"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="5dp"
                        android:ems="4"
                        android:inputType="number"
                        tools:ignore="Autofill"/>
                </TableRow>

                <TableRow
                    android:layout_width="match_parent"
                    android:layout_height="match_parent">

                    <TextView
                        android:id="@+id/textName2"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="@string/fortune" />

                    <EditText
                        android:id="@+id/editName2"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="5dp"
                        android:layout_weight="1"
                        android:ems="10"
                        android:inputType="text"
                        tools:ignore="Autofill" />

                    <TextView
                        android:id="@+id/textQuantity2"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="20dp"
                        android:text="@string/ratio" />

                    <EditText
                        android:id="@+id/editRatio2"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="5dp"
                        android:ems="4"
                        android:inputType="number" />
                </TableRow>

                <TableRow
                    android:layout_width="match_parent"
                    android:layout_height="match_parent">

                    <TextView
                        android:id="@+id/textName3"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="@string/fortune" />

                    <EditText
                        android:id="@+id/editName3"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="5dp"
                        android:layout_weight="1"
                        android:ems="10"
                        android:inputType="text"
                        tools:ignore="Autofill" />

                    <TextView
                        android:id="@+id/textQuantity3"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="20dp"
                        android:text="@string/ratio" />

                    <EditText
                        android:id="@+id/editRatio3"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="5dp"
                        android:ems="4"
                        android:inputType="number" />
                </TableRow>

                <TableRow
                    android:layout_width="match_parent"
                    android:layout_height="match_parent">

                    <TextView
                        android:id="@+id/textName4"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="@string/fortune" />

                    <EditText
                        android:id="@+id/editName4"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="5dp"
                        android:layout_weight="1"
                        android:ems="10"
                        android:inputType="text"
                        tools:ignore="Autofill" />

                    <TextView
                        android:id="@+id/textQuantity4"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="20dp"
                        android:text="@string/ratio" />

                    <EditText
                        android:id="@+id/editRatio4"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="5dp"
                        android:ems="4"
                        android:inputType="number" />
                </TableRow>

                <TableRow
                    android:layout_width="match_parent"
                    android:layout_height="match_parent">

                    <TextView
                        android:id="@+id/textName5"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="@string/fortune" />

                    <EditText
                        android:id="@+id/editName5"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="5dp"
                        android:layout_weight="1"
                        android:ems="10"
                        android:inputType="text"
                        tools:ignore="Autofill" />

                    <TextView
                        android:id="@+id/textQuantity5"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="20dp"
                        android:text="@string/ratio" />

                    <EditText
                        android:id="@+id/editRatio5"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="5dp"
                        android:ems="4"
                        android:inputType="number" />
                </TableRow>

                <TableRow
                    android:layout_width="match_parent"
                    android:layout_height="match_parent">

                    <TextView
                        android:id="@+id/textName6"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="@string/fortune" />

                    <EditText
                        android:id="@+id/editName6"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="5dp"
                        android:layout_weight="1"
                        android:ems="10"
                        android:inputType="text"
                        tools:ignore="Autofill" />

                    <TextView
                        android:id="@+id/textQuantity6"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="20dp"
                        android:text="@string/ratio" />

                    <EditText
                        android:id="@+id/editRatio6"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="5dp"
                        android:ems="4"
                        android:inputType="number" />
                </TableRow>

                <TableRow
                    android:layout_width="match_parent"
                    android:layout_height="match_parent">

                    <TextView
                        android:id="@+id/textName7"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="@string/fortune" />

                    <EditText
                        android:id="@+id/editName7"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="5dp"
                        android:layout_weight="1"
                        android:ems="10"
                        android:inputType="text"
                        tools:ignore="Autofill" />

                    <TextView
                        android:id="@+id/textQuantity7"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="20dp"
                        android:text="@string/ratio" />

                    <EditText
                        android:id="@+id/editRatio7"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="5dp"
                        android:ems="4"
                        android:inputType="number" />
                </TableRow>

            </TableLayout>

            <View
                android:id="@+id/divider5"
                android:layout_width="match_parent"
                android:layout_height="1dp"
                android:layout_marginTop="30dp"
                android:background="?android:attr/listDivider" />


            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="10dp"
                android:orientation="horizontal">

                <TextView
                    android:id="@+id/textSpeed"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/animationSpeed"
                    android:textColor="?android:attr/textColorPrimary" />

                <EditText
                    android:id="@+id/editSpeed"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginStart="10dp"
                    android:layout_weight="1"
                    android:ems="6"
                    android:inputType="number" />

            </LinearLayout>

            <TextView
                android:id="@+id/textView7"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="@string/speed1" />

            <View
                android:id="@+id/divider1"
                android:layout_width="match_parent"
                android:layout_height="1dp"
                android:layout_marginTop="20dp"
                android:background="?android:attr/listDivider" />

            <androidx.appcompat.widget.SwitchCompat
                android:id="@+id/switchTheme"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="10dp"
                android:text="@string/darkTheme" />

            <View
                android:id="@+id/divider6"
                android:layout_width="match_parent"
                android:layout_height="1dp"
                android:layout_marginTop="10dp"
                android:background="?android:attr/listDivider" />

            <TextView
                android:id="@+id/textLanguage"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="20dp"
                android:text="@string/language"
                android:textColor="?android:attr/textColorPrimary" />

            <RadioGroup
                android:layout_width="match_parent"
                android:layout_height="match_parent" >
                <RadioButton
                    android:id="@+id/radioLanguageSystem"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="@string/languageSystem" />
                <RadioButton
                    android:id="@+id/radioLanguageEn"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="@string/languageEn" />
                <RadioButton
                    android:id="@+id/radioLanguageJa"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="@string/languageJa" />

            </RadioGroup>

            <View
                android:id="@+id/divider2"
                android:layout_width="match_parent"
                android:layout_height="1dp"
                android:layout_marginTop="10dp"
                android:background="?android:attr/listDivider" />

            <TextView
                android:id="@+id/textUsage"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="20dp"
                android:text="@string/usage" />

            <TextView
                android:id="@+id/textUsage1"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="@string/usage1" />

            <View
                android:id="@+id/divider3"
                android:layout_width="match_parent"
                android:layout_height="1dp"
                android:layout_marginTop="20dp"
                android:background="?android:attr/listDivider" />

            <Space
                android:layout_width="match_parent"
                android:layout_height="120dp" />

        </LinearLayout>
    </ScrollView>

</androidx.constraintlayout.widget.ConstraintLayout>
このページでお気付きの点がございましたら
ご連絡いただけますと幸いです。
Eメール(任意)
送信内容
 

■ 便利ウェブサイト