2016-11-28 10 views
1

多くのボタンのUIを作成して、制約レイアウトでテキストを入力します。 たとえば、次の画像。これはAndroid Studioのバグですか?

enter image description here

しかし、.IT(ex.someボタンが画像の上disapper先頭行を許可する)時に消え、必要がある私はより多くのUIを置くようアンドロイドスタジオが非常に遅くなることを奇妙に感じると適応フックは、私が設定可能に非常に大きなメモリを使用し、私は位置を計算し、UIを再レンダリングするために空きメモリを推測します。 このような状況を避けることはできますか?または別のレイアウトを使用して同じUIを作成する別の方法です。私はグリッドフレキシブルスケーリングUIを作るための最善の方法を理解できないので、この問題は非常に緊張しています。

+0

Android Studio visual ConstraintLayoutエディタはまだベータ版であり、遅い(特に大きなレイアウトの場合)傾向があります。私はあなたがそれを行うことができるとは思わないので、GridLayoutなどをご覧ください。 ConstraintLayout(Android上)は、単純なRelativeLayoutよりも_slower_できるので、特定のレイアウトでのみ推奨されます。 CLayoutのメリットは、深層階層を使用して平坦化できる階層がある場合です。さもなければ、それは多くのものを計算するために遅くなることがあります。 –

+0

@MartínMarconcini返信いただきありがとうございます。まさにそうです。より相対的なポジショニングがつながるほど、遅くなります。それで、うまくいくでしょう。他のレイアウトでは、ビュー項目を囲む親コンポーネントが少なくなります。ありがとう。 – tkowt

答えて

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" /> ・・・・・・ 

あなたは好きなものを置くことができます。

関連する問題