<Splash>
splash 화면을 만들어준다.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
package com.uzi98.twice
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.os.Handler
class SplashActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_splash)
Handler().postDelayed({
startActivity(Intent(this,MainActivity::class.java))
finish()
},3000)
}
}
|
cs |
Handler().postDelayed({
startActivity(Intent(this,MainActivity::class.java))
finish()
},3000)
3초 뒤에 메인으로 넘어간다.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.uzi98.twice">
<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.Twice">
<activity
android:name=".SplashActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".MainActivity"
android:exported="true">
</activity>
</application>
</manifest>
|
cs |
그리고 메니페스트에서,
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
부분을 splash activity 사이에 넣어주면 splash activity부터 실행이된다.
< 사진 둥글게 >
![](https://blog.kakaocdn.net/dn/cuGy1D/btreJxpyaE7/0rpCPDRhcAd2TUgDswsKPK/img.png)
1
2
3
4
5
6
7
8
9
10
11
12
13
|
<androidx.cardview.widget.CardView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
app:cardCornerRadius="50dp">
<ImageView
android:id="@+id/member1"
android:layout_width="100dp"
android:layout_height="120dp"
android:scaleType="fitXY"
android:src="@drawable/member_1">
</ImageView> </androidx.cardview.widget.CardView>
|
cs |
|
|
cardView의 app:cardCornerRadius="50dp" 를 통해서 둥글게 만들 수 있다.
android:scaleType="fitXY" // 둥글게 된 뷰를 꽉 채우는 효과
<Notitle>
Theme.xml 파일에서
<item name="windowNoTitle">true</item>
추가해준다.
<하나의 레이아웃으로 시도마다 다른 사진을 출력>
btn1.setOnClickListener{
val intent = Intent(this, ImageInsideActivity::class.java)
intent.putExtra("data","1")
startActivity(intent)
}
(Main)
ImageInsideActivity 라는 새로운 class를 만듭니다.
intent.putExtra("data","1") 그리고 이제 intent에 정보를 저장해서 보내는데
(ImageInsideActivity)
val getData = intent.getStringExtra("data") // 정보를 받아서 그 값에 따라
val memberImage = findViewById<ImageView>(R.id.memberNumber)
if(getData == "1"){ // 이런식으로 이미지를 변경해줍니다
memberImage.setImageResource(R.drawable.member_1)
}
'공부기록 > 코틀린 시작하기' 카테고리의 다른 글
주사위 앱 (0) | 2021.09.10 |
---|---|
ListView (0) | 2021.09.07 |
안드로이드 custom font (0) | 2021.09.06 |
background 색 변경, 타이틀 제거 (0) | 2021.09.05 |
Log.d (0) | 2021.09.04 |