質問編集履歴
2
初心者マークの追加、該当のソースコードの追加、前提・実現したいことの変更
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,13 +1,56 @@
|
|
1
1
|
### 前提・実現したいこと
|
2
2
|
|
3
|
-
関数が知りたいのでプログラムの指定などは特にありません。
|
4
3
|
ボタンやテキストなどの色ではなく画面背景全体の色だけを動的に変更したい
|
5
|
-
Javaで背景色を変する
|
4
|
+
Javaで背景色を動的に変更する方法を教えてもらいたいです。
|
6
5
|
|
7
6
|
### 発生している問題・エラーメッセージ
|
8
7
|
|
9
8
|
自分で調べてみたもののテキスト内の色を変更するものしか出てこらずどのような関数を書き加えればいいかわからない
|
10
9
|
|
10
|
+
### 該当のソースコード
|
11
|
+
|
12
|
+
コードは初期のものです。
|
13
|
+
|
14
|
+
activity_main.xml
|
15
|
+
```xml
|
16
|
+
<?xml version="1.0" encoding="utf-8"?>
|
17
|
+
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
18
|
+
xmlns:app="http://schemas.android.com/apk/res-auto"
|
19
|
+
xmlns:tools="http://schemas.android.com/tools"
|
20
|
+
android:layout_width="match_parent"
|
21
|
+
android:layout_height="match_parent"
|
22
|
+
tools:context=".MainActivity">
|
23
|
+
|
24
|
+
<TextView
|
25
|
+
android:layout_width="wrap_content"
|
26
|
+
android:layout_height="wrap_content"
|
27
|
+
android:text="Hello World!"
|
28
|
+
app:layout_constraintBottom_toBottomOf="parent"
|
29
|
+
app:layout_constraintLeft_toLeftOf="parent"
|
30
|
+
app:layout_constraintRight_toRightOf="parent"
|
31
|
+
app:layout_constraintTop_toTopOf="parent" />
|
32
|
+
|
33
|
+
</androidx.constraintlayout.widget.ConstraintLayout>
|
34
|
+
```
|
35
|
+
|
36
|
+
MainActivity.java
|
37
|
+
```java
|
38
|
+
package com.example.myapplication;
|
39
|
+
|
40
|
+
import androidx.appcompat.app.AppCompatActivity;
|
41
|
+
|
42
|
+
import android.os.Bundle;
|
43
|
+
|
44
|
+
public class MainActivity extends AppCompatActivity {
|
45
|
+
|
46
|
+
@Override
|
47
|
+
protected void onCreate(Bundle savedInstanceState) {
|
48
|
+
super.onCreate(savedInstanceState);
|
49
|
+
setContentView(R.layout.activity_main);
|
50
|
+
}
|
51
|
+
}
|
52
|
+
```
|
53
|
+
|
11
54
|
### 補足情報(FW/ツールのバージョンなど)
|
12
55
|
|
13
56
|
Android Studio 4.1
|
1
前提・実現したいこと に文章追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
### 前提・実現したいこと
|
2
2
|
|
3
|
+
関数が知りたいのでプログラムの指定などは特にありません。
|
3
4
|
ボタンやテキストなどの色ではなく画面背景全体の色だけを動的に変更したい
|
4
5
|
Javaで背景色を変するための関数を教えてもらいたいです。
|
5
6
|
|