Android 猜拳遊戲

      在〈Android 猜拳遊戲〉中尚無留言

Android 猜拳遊戲

build.gradle

gradle為設定編譯時的條件,請新增如下藍色的部份。此法就可以在MainActivity.kt中直接使用layout裏的元件,不需使用 findViewById了。

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

AndroidManifes.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.asuscomm.mahaljsp.game">
<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.AppCompat.Light.NoActionBar"> <==取消標題列
<activity
android:name=".MainActivity"
android:screenOrientation="landscape" <==限定橫向顯示
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

Layout

不論 ImageView 或 ImageButton,靜態更改圖片的方法都是設定src即可。但圖片通常會超出元件的邊框,所以需將 scaleType 設定為 “fitCenter” 對圖片進行縮放,如下所示

🔒 底下內容僅限會員閱讀。

立即登入

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *