这是Android Studio的错误吗?

时间:2016-11-28 18:47:18

标签: android android-layout android-studio-2.2

我通过约束布局制作许多按钮的UI来输入文本。 例如,下图。

enter image description here

但是,我觉得奇怪的是android studio变得非常慢,因为我放了更多的UI和自适应钩子允许我设置,有时消失(ex.some按钮'允许disapper head row在图像上方)。它应该使用非常大的内存我想自由记忆计算位置并重新渲染UI。 我可以避免这种情况吗?或使用其他布局制作相同UI的替代方法。我对此问题非常紧张,因为我无法理解制作网格灵活扩展UI的最佳方法。任何提示都会对我有帮助。

1 个答案:

答案 0 :(得分:0)

我可以使用包含按钮嵌套约束视图的网格布局解决问题,这似乎是相对定位UI的最佳方式。

<?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">

<EditText
        android:layout_width="456dp"
        android:layout_height="64dp"
        android:inputType="textPersonName"
        android:text="Name"
        android:ems="10"
        android:id="@+id/editText"
        android:layout_marginTop="16dp"
        app:layout_constraintTop_toTopOf="parent"
        android:layout_marginStart="16dp"
        app:layout_constraintLeft_toLeftOf="parent"
        android:layout_marginEnd="16dp"
        app:layout_constraintRight_toRightOf="parent" />

    <GridLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:columnCount="8"
        android:rowCount="5"
        android:useDefaultMargins="true"
        app:layout_constraintBottom_toBottomOf="parent"
        android:layout_marginBottom="32dp"
        android:foregroundGravity="center_horizontal"
        android:layout_marginStart="16dp"
        app:layout_constraintLeft_toLeftOf="parent"
        android:layout_marginEnd="16dp"
        app:layout_constraintRight_toRightOf="parent"
        android:layout_marginTop="8dp"
        app:layout_constraintTop_toBottomOf="@+id/editText"
        app:layout_constraintVertical_bias="0.81">

        <Button
            android:text="button"
            android:layout_width="88dp"
            android:background="@drawable/oval_btn"
            android:id="@+id/str_wa"
            android:layout_height="88dp"
            tools:layout_editor_absoluteY="520dp"
            tools:layout_editor_absoluteX="529dp" /> ・・・・・・

你可以放置自己喜欢的东西。

相关问题