gpt4 book ai didi

java - 我的拖放功能在 Android Studio 中不起作用

转载 作者:行者123 更新时间:2023-12-02 09:18:27 25 4
gpt4 key购买 nike

正如您在上图中看到的,当您拖动某些内容时,有对齐选项“to RightOf=button”、“below=button”,但是当我拖动某些内容时,不会显示类似的内容。谁能帮我解决这个问题吗?

Image

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context=".MainActivity"
tools:showIn="@layout/activity_main">


<TextView
android:id="@+id/text_witaj_uzytkowniku"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/witaj_uzytkowniku" />

</RelativeLayout>

最佳答案

老实说,我更喜欢使用 ConstraintLayout 作为根。我相信使用拖放工具会更容易使用。

使用时请确保 all objects are connected to each other (或父级)至少垂直一次和水平一次。这在代码中看起来如何:

<androidx.constraintlayout.widget.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">

<TextView
android:id="@+id/textView9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:layout_marginTop="24dp"
android:text="TextView"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<TextView
android:id="@+id/textView10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="TextView"
app:layout_constraintStart_toStartOf="@+id/textView9"
app:layout_constraintTop_toBottomOf="@+id/textView9" />
</androidx.constraintlayout.widget.ConstraintLayout>

您还可以使用 side panel 调整距离.

要使用该布局,您只需在Pallete中输入Constraint布局并拖动它(如果未安装,将有一个下载)

关于java - 我的拖放功能在 Android Studio 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58853568/

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