【问题标题】:Cannot move the text box on Android Layout page无法在 Android 布局页面上移动文本框
【发布时间】:2014-12-11 23:09:20
【问题描述】:

我正在尝试设计我的 Android 项目的布局,但我一定做错了什么。现在,当我尝试拖动文本框时,它们只是不会在屏幕上移动。我猜这是格式设置之一,但不确定是哪一个。

这是其外观的 XML 文件:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/container"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.oldimagerevieal.MainActivity"
    tools:ignore="MergeRootFrame" >

    <TextView
        android:id="@+id/textLat"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Medium Text"
        android:textAppearance="?android:attr/textAppearanceMedium" />

    <TextView
        android:id="@+id/textLong"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Medium Text"
        android:textAppearance="?android:attr/textAppearanceMedium" />

</FrameLayout>

【问题讨论】:

  • 您能翻到 .xml 并为我们发布吗?
  • 已发布。只是添加了两个标签,但根本无法拖动它们。 :-(

标签: android eclipse android-layout


【解决方案1】:

FrameLayouts 使用重力在屏幕上使用

android:layout_gravity="left|top" //whatever you want. 

除非您需要 FrameLayout,否则您可以将根元素更改为 RelativeLayout 或 LinearLayout(不要忘记指定方向),并且您应该能够像往常一样拖动东西。

我强烈建议您熟悉在 XML 中构建视图。它将极大地帮助您。

【讨论】:

    【解决方案2】:

    通过单击设计工具部分中的磁铁按钮启用“自动连接到父级”。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-05
      • 2016-10-11
      • 2021-03-20
      • 1970-01-01
      相关资源
      最近更新 更多