###前提・発生している問題・実現したいこと
EditTextに単語を入力し、検索ボタンを押すとその単語の意味が表示されるアプリを構築したいと考えており、そのためのパーツを「activity_main.xml」に設置させようと考えています。
しかし、「activity_main.xml」のDesignの箇所では自分の意図した正しい位置でパーツが表示されるのに、実際に実行してみると、Designとは違った位置でパーツが表示されてしまいます。
そこで、Design通りの位置にパーツを表示させる方法を教えていただきたいと思って質問しました。よろしくお願いします。
ちなみにパーツは、上から順に
①検索したい単語を入力する部分(EditText)
②押すと実際に検索を行うボタンと、押すと上のEditTextを空白に戻す消去ボタン(両方ともButton)
③単語の意味が表示される部分(TextView、長すぎても表示出来るようSchollViewを付けている)
です。
###該当のソースコード
activity_main.xml
<?xml version="1.0" encoding="utf-8"?> <android.support.constraint.ConstraintLayout 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" tools:context="「Company domainやApplication nameなどが書かれている」.MainActivity"> <EditText android:id="@+id/editText" android:layout_width="wrap_content" android:layout_height="wrap_content" android:ems="10" android:inputType="textPersonName" tools:layout_editor_absoluteX="16dp" tools:layout_editor_absoluteY="16dp" /> <Button android:id="@+id/button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginEnd="8dp" android:layout_marginRight="8dp" android:onClick="onClickButton1" android:text="検索" app:layout_constraintRight_toRightOf="parent" tools:layout_editor_absoluteY="59dp" /> <Button android:id="@+id/button2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:onClick="onClickButton2" android:text="消去" tools:layout_editor_absoluteX="192dp" tools:layout_editor_absoluteY="59dp" /> <ScrollView android:layout_width="368dp" android:layout_height="388dp" tools:layout_editor_absoluteX="8dp" tools:layout_editor_absoluteY="115dp"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <TextView android:layout_width="match_parent" android:layout_height="match_parent" /> </LinearLayout> </ScrollView> </android.support.constraint.ConstraintLayout>
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/04/21 18:04
2017/04/21 23:56
2017/04/22 08:16