前提・実現したいこと
デフォルトの状態からドラッグ&ドロップでButtonを配置しても、Buttonが配置されているように見えないのですが、
どういった対処をすればよいですか?
ご教示お願いします。
該当のソースコード
xml
1<?xml version="1.0" encoding="utf-8"?> 2<android.support.constraint.ConstraintLayout 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 tools:context=".MainActivity"> 8 9 <TextView 10 android:layout_width="wrap_content" 11 android:layout_height="wrap_content" 12 android:text="Hello World!" 13 app:layout_constraintBottom_toBottomOf="parent" 14 app:layout_constraintLeft_toLeftOf="parent" 15 app:layout_constraintRight_toRightOf="parent" 16 app:layout_constraintTop_toTopOf="parent" /> 17 18 <Button 19 android:id="@+id/button" 20 android:layout_width="wrap_content" 21 android:layout_height="wrap_content" 22 android:text="Button" 23 tools:layout_editor_absoluteX="111dp" 24 tools:layout_editor_absoluteY="376dp" /> 25 26</android.support.constraint.ConstraintLayout>
試したこと
こちらを参考にしましたが、
ConstraintLayoutが置かれているようなので、「先にLayoutを置く」という条件は満たされているようです。
TextView が全面覆っているようですが, 重なっているだけということはありませんか.
ご指摘ありがとうございます。
TextViewの値をいじってみましたが、今の所、変化なしでした。
https://original-game.com/develop-android-app-7/
こちらの記事と同じXMLになっているはずなので不思議です。
また、2つエラーメッセージが出ていることに気づきました。
Failed to load AppCompat ActionBar with unknown error.
This view is not constrained. It only has designtime positions, so it will jump to (0,0) at runtime unless you add the constraints
引き続き調べます。
original-game.com さんの記事は続きモノのようですが, android studio のバージョンやプロジェクトの設定, 選択した Activity など, develop-android-app-7 までの記事と tkmnusrさんの現状で異なる部分はありませんか?
全く同じなのでしょうか.
ご指摘ありがとうございます。
バージョンが気になって、アップデートをかけてみたら、ボタンが表示されるようになりました。
ありがとうございました。
回答2件
あなたの回答
tips
プレビュー