質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
CSV

CSV(Comma-Separated Values)はコンマで区切られた明白なテキスト値のリストです。もしくは、そのフォーマットでひとつ以上のリストを含むファイルを指します。

Java

Javaは、1995年にサン・マイクロシステムズが開発したプログラミング言語です。表記法はC言語に似ていますが、既存のプログラミング言語の短所を踏まえていちから設計されており、最初からオブジェクト指向性を備えてデザインされています。セキュリティ面が強力であることや、ネットワーク環境での利用に向いていることが特徴です。Javaで作られたソフトウェアは基本的にいかなるプラットフォームでも作動します。

Android

Androidは、Google社が開発したスマートフォンやタブレットなど携帯端末向けのプラットフォームです。 カーネル・ミドルウェア・ユーザーインターフェイス・ウェブブラウザ・電話帳などのアプリケーションやソフトウェアをひとつにまとめて構成。 カーネル・ライブラリ・ランタイムはほとんどがC言語/C++、アプリケーションなどはJavaSEのサブセットとAndroid環境で書かれています。

Android Studio

Android Studioは、 Google社によって開発された、 Androidのネイティブアプリケーション開発に特化した統合開発ツールです。

Q&A

解決済

2回答

329閲覧

Android Studio 画面のレイアウトを整えたい

sekaikan_ozaki

総合スコア65

CSV

CSV(Comma-Separated Values)はコンマで区切られた明白なテキスト値のリストです。もしくは、そのフォーマットでひとつ以上のリストを含むファイルを指します。

Java

Javaは、1995年にサン・マイクロシステムズが開発したプログラミング言語です。表記法はC言語に似ていますが、既存のプログラミング言語の短所を踏まえていちから設計されており、最初からオブジェクト指向性を備えてデザインされています。セキュリティ面が強力であることや、ネットワーク環境での利用に向いていることが特徴です。Javaで作られたソフトウェアは基本的にいかなるプラットフォームでも作動します。

Android

Androidは、Google社が開発したスマートフォンやタブレットなど携帯端末向けのプラットフォームです。 カーネル・ミドルウェア・ユーザーインターフェイス・ウェブブラウザ・電話帳などのアプリケーションやソフトウェアをひとつにまとめて構成。 カーネル・ライブラリ・ランタイムはほとんどがC言語/C++、アプリケーションなどはJavaSEのサブセットとAndroid環境で書かれています。

Android Studio

Android Studioは、 Google社によって開発された、 Androidのネイティブアプリケーション開発に特化した統合開発ツールです。

0グッド

0クリップ

投稿2019/05/22 02:35

PCスペック
Windows7 64bit
メモリ 8GB
プロセッサ Intel Core i7-3610

Android Studio 3.4

アプリの画面で、CSVで読み込んだデータを表示する上部に、文字入力するためのEditextとButtonを追加したいです。(とりあえずButtonを押すと、EditTextで打ち込んだ文字がそのまま表示される機能をがあれば良い)

しかし、layoutファイルの書き方が正しくないせいで、現段階ではこのように表示されてしまいます。
イメージ説明

理想は、EditextとButtonが画面の一番上で中央に表示され、その下に、CSVで読み込んだデータ類(ここではItem1だとかのリスト)を画面いっぱいに並べる形に仕上げたいです。。

xml

1<?xml version="1.0" encoding="utf-8"?> 2<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 3 xmlns:app="http://schemas.android.com/apk/res-auto" 4 xmlns:tools="http://schemas.android.com/tools" 5 android:layout_width="match_parent" 6 android:layout_height="match_parent"> 7 8 9 <TextView 10 android:id="@+id/text_view" 11 android:layout_width="wrap_content" 12 android:layout_height="wrap_content" 13 android:gravity="center" 14 android:textSize="30sp" 15 app:layout_constraintBottom_toBottomOf="parent" 16 app:layout_constraintHorizontal_bias="0.6" 17 app:layout_constraintLeft_toLeftOf="parent" 18 app:layout_constraintRight_toRightOf="parent" 19 app:layout_constraintTop_toTopOf="parent" 20 app:layout_constraintVertical_bias="0.15" /> 21 22 <EditText 23 android:id="@+id/edit_text" 24 android:layout_width="wrap_content" 25 android:layout_height="wrap_content" 26 android:autofillHints="@string/hint" 27 android:background="#ffffff" 28 android:hint="@string/hint" 29 android:inputType="text" 30 app:layout_constraintBottom_toBottomOf="parent" 31 app:layout_constraintLeft_toLeftOf="parent" 32 app:layout_constraintRight_toRightOf="parent" 33 app:layout_constraintTop_toTopOf="parent" 34 app:layout_constraintVertical_bias="0.3" /> 35 36 <Button 37 android:id="@+id/button" 38 android:layout_width="wrap_content" 39 android:layout_height="wrap_content" 40 android:text="@string/button" 41 app:layout_constraintBottom_toBottomOf="parent" 42 app:layout_constraintLeft_toLeftOf="parent" 43 app:layout_constraintRight_toRightOf="parent" 44 app:layout_constraintTop_toTopOf="parent" 45 app:layout_constraintVertical_bias="0.45" /> 46 47 <ListView 48 android:id="@+id/list_view1" 49 android:layout_width="0dp" 50 android:layout_height="match_parent" 51 android:layout_weight="1"></ListView> 52 53 <ListView 54 android:id="@+id/list_view2" 55 android:layout_width="0dp" 56 android:layout_height="match_parent" 57 android:layout_weight="1"></ListView> 58 59 <ListView 60 android:id="@+id/list_view3" 61 android:layout_width="0dp" 62 android:layout_height="match_parent" 63 android:layout_weight="1"></ListView> 64 65 66</LinearLayout> 67 68

現状では、<LinearLayout>で囲っているだけなので、この表示のされ方になってしまったのですが、これを直す方法はどのようなものが考えられますでしょうか??

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答2

0

自己解決

xml

1<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 2 xmlns:app="http://schemas.android.com/apk/res-auto" 3 xmlns:tools="http://schemas.android.com/tools" 4 android:layout_width="match_parent" 5 android:layout_height="match_parent" 6 android:orientation="vertical"> 7 8 9 <TextView 10 android:id="@+id/text_view" 11 android:layout_width="wrap_content" 12 android:layout_height="wrap_content" 13 android:gravity="center" 14 android:layout_gravity="center" 15 android:textSize="30sp" 16 app:layout_constraintBottom_toBottomOf="parent" 17 app:layout_constraintHorizontal_bias="0.6" 18 app:layout_constraintLeft_toLeftOf="parent" 19 app:layout_constraintRight_toRightOf="parent" 20 app:layout_constraintTop_toTopOf="parent" 21 app:layout_constraintVertical_bias="0.15" /> 22 23 <EditText 24 android:id="@+id/edit_text" 25 android:layout_width="wrap_content" 26 android:layout_height="wrap_content" 27 android:autofillHints="@string/hint" 28 android:background="#ffffff" 29 android:layout_gravity="center" 30 android:hint="@string/hint" 31 android:inputType="text" 32 app:layout_constraintBottom_toBottomOf="parent" 33 app:layout_constraintLeft_toLeftOf="parent" 34 app:layout_constraintRight_toRightOf="parent" 35 app:layout_constraintTop_toTopOf="parent" 36 app:layout_constraintVertical_bias="0.3" /> 37 38 <Button 39 android:id="@+id/button" 40 android:layout_width="wrap_content" 41 android:layout_height="wrap_content" 42 android:layout_gravity="center" 43 android:text="@string/button" 44 app:layout_constraintBottom_toBottomOf="parent" 45 app:layout_constraintLeft_toLeftOf="parent" 46 app:layout_constraintRight_toRightOf="parent" 47 app:layout_constraintTop_toTopOf="parent" 48 app:layout_constraintVertical_bias="0.45" /> 49 50 <LinearLayout 51 android:layout_width="match_parent" 52 android:layout_height="match_parent" 53 android:orientation="horizontal" 54 > 55 56 <ListView 57 android:id="@+id/list_view1" 58 android:layout_width="0dp" 59 android:layout_height="match_parent" 60 android:layout_weight="1"></ListView> 61 62 <ListView 63 android:id="@+id/list_view2" 64 android:layout_width="0dp" 65 android:layout_height="match_parent" 66 android:layout_weight="1"></ListView> 67 68 <ListView 69 android:id="@+id/list_view3" 70 android:layout_width="0dp" 71 android:layout_height="match_parent" 72 android:layout_weight="1"></ListView> 73 </LinearLayout> 74</LinearLayout> 75

このように書き換えたところ、正しく表示ができました

投稿2019/05/22 04:51

sekaikan_ozaki

総合スコア65

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

0

android:orientationで並べる方向を指定します。(中央寄せやサイズは省略しています。)

xml

1<LinearLayout android:orientation="vertical"> 2 <LinearLayout android:orientation="horizontal"> 3 <TextView /> 4 <EditText /> 5 <Button /> 6 </LinearLayout> 7 <LinearLayout android:orientation="horizontal"> 8 <ListView /> 9 <ListView /> 10 <ListView /> 11 </LinearLayout> 12</LinearLayout>

投稿2019/05/22 02:48

dsuzuki

総合スコア1682

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

sekaikan_ozaki

2019/05/22 03:05

返信ありがとうございます! 参考に、このように書き換えてみたのですが、エラーが出てしまいます。 別な部分でおかしなところがありませんでしょうか?? ```xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout 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" android:orientation="vertical"> <LinearLayout android:orientation="horizontal"> <TextView android:id="@+id/text_view" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center" android:textSize="30sp" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintHorizontal_bias="0.6" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toRightOf="parent" app:layout_constraintTop_toTopOf="parent" app:layout_constraintVertical_bias="0.15" /> <EditText android:id="@+id/edit_text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:autofillHints="@string/hint" android:background="#ffffff" android:hint="@string/hint" android:inputType="text" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toRightOf="parent" app:layout_constraintTop_toTopOf="parent" app:layout_constraintVertical_bias="0.3" /> <Button android:id="@+id/button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/button" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toRightOf="parent" app:layout_constraintTop_toTopOf="parent" app:layout_constraintVertical_bias="0.45" /> </LinearLayout> <LinearLayout android:orientation="horizontal"> <ListView android:id="@+id/list_view1" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1"></ListView> <ListView android:id="@+id/list_view2" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1"></ListView> <ListView android:id="@+id/list_view3" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1"></ListView> </LinearLayout> </LinearLayout> ```
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問