gpt4 book ai didi

android - ConstraintLayout 不允许我设置将 View 连接到屏幕边缘的约束

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:12:40 25 4
gpt4 key购买 nike

Here's the image for what it looks like right now.我希望 float 操作按钮位于屏幕底部。 Here's me trying to do that.好的,这是 activity_main 文件:

<?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"
android:fitsSystemWindows="true"
tools:context="com.example.jaden.finances.MainActivity">


<android.support.v7.widget.Toolbar
android:id="@+id/appBarLayout"
android:layout_width="360dp"
android:layout_height="81dp"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay"
tools:layout_editor_absoluteY="0dp"
tools:layout_editor_absoluteX="0dp" />


<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="40dp"
android:layout_height="40dp"
app:srcCompat="@android:drawable/ic_dialog_email"
tools:layout_editor_absoluteY="0dp"
tools:layout_editor_absoluteX="0dp" />

<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="text"
android:text="Name"
android:ems="10"
android:id="@+id/editText"
android:hint="@string/edit_message"
tools:layout_editor_absoluteY="83dp"
tools:layout_editor_absoluteX="16dp" />

<Button
android:text="@string/button_send"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/button3"
android:onClick="sendMessage"
tools:layout_editor_absoluteX="249dp"
tools:layout_editor_absoluteY="81dp" />

<ScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:layout_editor_absoluteY="126dp"
tools:layout_editor_absoluteX="8dp">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="@+id/options">

</LinearLayout>
</ScrollView>
</android.support.constraint.ConstraintLayout>

我不确定我做错了什么。当我进入图形设计编辑器并单击并拖动边缘以创建新约束时,它不会锁定到屏幕边缘。谷歌搜索没有任何结果。

最佳答案

I set the floating action button to be right at the bottom of the screen.But don't know about the scroll-view position so I place it below edit text.

<?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"
android:fitsSystemWindows="true"
tools:context=".MainActivity">

<android.support.v7.widget.Toolbar
android:id="@+id/appBarLayout"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginBottom="20dp"
android:layout_marginRight="20dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:srcCompat="@android:drawable/ic_dialog_email" />

<EditText
android:id="@+id/editText"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginTop="8dp"
android:ems="10"
android:hint="Name"
android:inputType="text"
android:text="Name"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@+id/appBarLayout" />

<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="sendMessage"
android:text="Send"
app:layout_constraintLeft_toRightOf="@+id/editText"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@+id/editText" />

<ScrollView
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/editText">

<LinearLayout
android:id="@+id/options"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">

</LinearLayout>
</ScrollView>

关于android - ConstraintLayout 不允许我设置将 View 连接到屏幕边缘的约束,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45524304/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com