Very new so please excuse misuse of terms.
I'm following an Android development course to build a basic app. I created a text view and then a button. The button should sit below the text view after using android:layout_below="@id/rollResult"
but instead the button overlaps the text.
Adding and removing that line from my code has no effect on the botton's layout position. Changing this line android:layout_centerHorizontal="true"
from true to false and back also has no effect.
Code:
<?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:id="@+id/content_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="16dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="16dp"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.example.diceout.MainActivity"
tools:showIn="@layout/activity_main"
tools:layout_editor_absoluteY="81dp"
tools:layout_editor_absoluteX="0dp">
<TextView
android:id="@+id/rollResult"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="The play App"
/>
<Button
android:id="@+id/rollButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/rollResult"
android:layout_centerHorizontal="true"
android:onClick="rollDice"
android:text="Roll" />
Any help is much appreciated.
将您的ConstraintLayout
更改为RelativeLayout
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.