質問編集履歴

3

レイアウトの追加

2022/04/24 13:10

投稿

Lily_V
Lily_V

スコア12

test CHANGED
File without changes
test CHANGED
@@ -12,7 +12,29 @@
12
12
  ```java
13
13
  TextView textSpecial = new TextView(getActivity());
14
14
  String text = record.get(CLM_SPECIAL); //デバッグ: text = 1. MV\n2. メイキング映像
15
+ textSpecial.setText(text);
16
+ textSpecial.setTextSize(18);
17
+ textSpecial.setPadding(50, 0, 0, 0);
15
- textSpecial.setText(text);![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2022-04-24/5622c382-b62b-416c-a7c5-bf6156abe8ec.png)
18
+ textSpecial.setLayoutParams(new LinearLayout.LayoutParams(
19
+ LinearLayout.LayoutParams.MATCH_PARENT,
20
+ LinearLayout.LayoutParams.WRAP_CONTENT));
21
+ layoutSpecialContents.addView(textSpecial);
22
+ ```
23
+ ■レイアウト
24
+ ```xml
25
+ <LinearLayout
26
+ android:id="@+id/layout_special_contents"
27
+ android:layout_width="match_parent"
28
+ android:layout_height="wrap_content"
29
+ android:layout_marginBottom="20dp"
30
+ android:orientation="vertical">
31
+
32
+ <TextView
33
+ android:layout_width="match_parent"
34
+ android:layout_height="wrap_content"
35
+ android:text="@string/lblSpecial"
36
+ android:textColor="@color/colorPrimary"
37
+ android:textSize="18sp" />
16
38
  ```
17
39
  ![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2022-04-24/83252e96-c6eb-4645-8830-7f93aab88b25.png)
18
40
 

2

画像が大きすぎたので差し替え

2022/04/24 13:04

投稿

Lily_V
Lily_V

スコア12

test CHANGED
File without changes
test CHANGED
@@ -12,14 +12,16 @@
12
12
  ```java
13
13
  TextView textSpecial = new TextView(getActivity());
14
14
  String text = record.get(CLM_SPECIAL); //デバッグ: text = 1. MV\n2. メイキング映像
15
- textSpecial.setText(text);
15
+ textSpecial.setText(text);![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2022-04-24/5622c382-b62b-416c-a7c5-bf6156abe8ec.png)
16
16
  ```
17
- ![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2022-04-23/418ecd7d-d0e6-42ec-a3da-384f249d85dd.png)
17
+ ![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2022-04-24/83252e96-c6eb-4645-8830-7f93aab88b25.png)
18
18
 
19
19
  ### 試したこと
20
20
  1. SQLiteから取得する際に改行コードがエスケープされているのかと思い、改行コードを置換してみましたが、変わりありませんでした。
21
21
  ```java
22
22
  textSpecial.setText(text.replace("\\n", "\n"));
23
+
24
+ textSpecial.setText(text.replace("\r\n", "\n"));
23
25
  ```
24
26
  2. 以下のコードを追加したところ、全文表示されるようにはなりましたが、改行がされません。(「1. MV 2. メイキング映像」)
25
27
  ```java

1

試したことの追加

2022/04/23 12:31

投稿

Lily_V
Lily_V

スコア12

test CHANGED
File without changes
test CHANGED
@@ -9,19 +9,12 @@
9
9
  db.execSQL("INSERT INTO cdVersionTbl (titleCd, versionCd, special, hasFlg, favoriteFlg) VALUES(17, 2, '1. MV\n2. メイキング映像', 0, 0);");
10
10
  ```
11
11
  ■Activity
12
- 【改行されない】
13
12
  ```java
14
13
  TextView textSpecial = new TextView(getActivity());
15
14
  String text = record.get(CLM_SPECIAL); //デバッグ: text = 1. MV\n2. メイキング映像
16
15
  textSpecial.setText(text);
17
16
  ```
18
17
  ![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2022-04-23/418ecd7d-d0e6-42ec-a3da-384f249d85dd.png)
19
-
20
- 【改行される】
21
- ```java
22
- TextView textSpecial = new TextView(getActivity());
23
- textSpecial.setText("あああ\nいいい\nううう");
24
- ```
25
18
 
26
19
  ### 試したこと
27
20
  1. SQLiteから取得する際に改行コードがエスケープされているのかと思い、改行コードを置換してみましたが、変わりありませんでした。
@@ -32,5 +25,10 @@
32
25
  ```java
33
26
  textSpecial.setInputType(InputType.TYPE_CLASS_TEXT);
34
27
  ```
28
+ 3. レイアウトの問題で表示されていないだけかとも思いましたが、以下のコードでは全文表示されます。
29
+ ```java
30
+ TextView textSpecial = new TextView(getActivity());
31
+ textSpecial.setText("あああ\nいいい\nううう");
32
+ ```
35
33
 
36
34
  宜しくお願い致します。