Reputation: 468
I'm new to Android programming, and started using Android Studio to develop a very simple app. However, using the "Design" view in the XML file, the widgets are not being correctly placed.
See the image - there are two widgets - Button and TextView. They are positioned at different places within the "Design" view, but they show in the left top corner in the emulator.
Upvotes: 0
Views: 154
Reputation: 4643
Your button view is using tools attribute which is only work in preview not on device make sure you remove them and use appropriate attributes
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<TextView
android:id="@+id/tv"
android:text="adhfbkj"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"/>
<Button
android:text="button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="@+id/tv"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"/>
</android.support.constraint.ConstraintLayout>
Upvotes: 1