私はアンドロイドスタジオで初めてのアプリを作成しています。これは私の最初の問題です。制約レイアウトが機能しない、おそらくデザインエディタのバグ?
私はConstraintLayoutを試してみたいと思います。デザインエディタでConstraintLayoutを使ってレイアウトを作成しました(一緒にクリックします)。 Androidエミュレータでレイアウトを試すと、すべてのボタンが左上隅に移動しました:( 最初のプロジェクトを作成したときに自動的に生成された「Hello World」ラベルを除きます。ボタンは、app:layout_constraint ...で始まるいくつかのコード行が欠落しています。コードで確認できます。
私は間違っていますか、それともバグですか? 私は答えがうれしいです!:)
<?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="com.example.u0017007.coffeecounter.MainActivity">
<TextView
android:layout_width="136dp"
android:layout_height="30dp"
android:text="Hello World!"
android:textSize="24sp"
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.234" />
<Button
android:id="@+id/buttonAddCoffee"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:freezesText="false"
android:text="@string/add_coffee"
tools:layout_editor_absoluteX="16dp"
tools:layout_editor_absoluteY="231dp" />
<Button
android:id="@+id/buttonRemoveCoffee"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/remove_coffee"
tools:layout_editor_absoluteX="236dp"
tools:layout_editor_absoluteY="231dp" />
</android.support.constraint.ConstraintLayout>
利用RelativeLayoutの代わりConstraintLayoutをprocedd。 – Abhi
[ConstraintLayoutビューの左上隅の複製](https://stackoverflow.com/questions/42594033/constraintlayout-views-in-top-left-corner) –