ConstraintLayout
にUIエレメントの上にランダムなスペースがある状況があります。画像では、textInput
とseekBar
要素の上のスペースを参照してください。ConstraintLayoutの要素の上のスペース
タイプに基づいてカスタムフィールドのフォームを作成しています(例:数字入力、テキスト入力、スイッチなどがあります。受信したフィールドタイプとコンテンツのJSONArray
に基づいてフォームを動的に作成します。
数値入力、テキスト入力、スライダ(seekBar
)の3種類を除いて、すべてが完全に構築されます。そのコードに何かがあった場合、これらの3つのタイプだけでなく、各フラグメントの上にこのスペースがあったと主張するので、私はフォームを生成するコードを提供していません。ここで
番号入力用のレイアウトファイル(それは入力タイプと要素のid以外のテキスト入力のための1と全く同じに見える)です:
<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"
tools:context="our.package.name.custom_fields.type_slider.SliderFragment">
<TextView
android:id="@+id/displayText"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textAppearance="@style/Base.TextAppearance.AppCompat.Subhead"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<android.support.design.widget.TextInputLayout
android:id="@+id/input_layout"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/displayText">
<android.support.design.widget.TextInputEditText
android:id="@+id/number_input"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="number" />
</android.support.design.widget.TextInputLayout>
</android.support.constraint.ConstraintLayout>
そして、 SeekBarのレイアウトファイルは次のとおりです。
<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"
tools:context="our.package.name.custom_fields.type_slider.SliderFragment">
<TextView
android:id="@+id/displayText"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textAppearance="@style/Base.TextAppearance.AppCompat.Subhead"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<SeekBar
android:id="@+id/slider_view"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/displayText" />
</android.support.constraint.ConstraintLayout>
アイデアはありますか?
確かにそれは溶液でした。私はあなたの答えを投稿した2分後に文字通り説明する私の答えを掲示したので、私は時間内にそれを見ませんでした。ごめんなさい! :| – marienke
これは解決策ですか? – marienke