Home > database >  Unable to set view in bottom in constraint layout in android
Unable to set view in bottom in constraint layout in android

Time:11-13

This is my xml layout :

<?xml version="1.0" encoding="utf-8"?>
    <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:id="@ id/app_lock_create_pin_container"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_margin="@dimen/dp_16">
    
        <TextView
            android:id="@ id/tv_title"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="@dimen/dp_64"
            android:text="@string/set_your_pin"
            android:textColor="@color/gray"
            android:textSize="25sp"
            android:textStyle="bold"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />
    
        <TextView
            android:id="@ id/tv_subtitle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="@dimen/dp_20"
            android:text="@string/enter_a_4_digit_password"
            android:textSize="15sp"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@ id/tv_title" />
    
        <LinearLayout
            android:id="@ id/ln_pint_container"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="@dimen/dp_64"
            android:orientation="horizontal"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@ id/tv_subtitle">
    
            <EditText
                android:id="@ id/otp_edit_box1"
                android:layout_width="@dimen/dp_42"
                android:layout_height="@dimen/dp_42"
                android:layout_marginEnd="@dimen/dp_20"
                android:background="@drawable/edittext_curve_bg"
                android:focusable="true"
                android:focusableInTouchMode="true"
                android:gravity="center"
                android:inputType="numberPassword"
                android:maxLength="1"
                android:textSize="@dimen/sp_30"
                tools:ignore="LabelFor" />
    
            <EditText
                android:id="@ id/otp_edit_box2"
                android:layout_width="@dimen/dp_42"
                android:layout_height="@dimen/dp_42"
                android:layout_marginEnd="@dimen/dp_20"
                android:background="@drawable/edittext_curve_bg"
                android:focusable="true"
                android:focusableInTouchMode="true"
                android:gravity="center"
                android:inputType="numberPassword"
                android:maxLength="1"
                android:textSize="30sp"                tools:ignore="LabelFor" />
    
            <EditText
                android:id="@ id/otp_edit_box3"
                android:layout_width="@dimen/dp_42"
                android:layout_height="@dimen/dp_42"
                android:layout_marginEnd="@dimen/dp_20"
                android:background="@drawable/edittext_curve_bg"
                android:focusable="true"
                android:focusableInTouchMode="true"
                android:gravity="center"
                android:inputType="numberPassword"
                android:maxLength="1"
                android:textSize="30sp"
              tools:ignore="LabelFor" />  
            <EditText
                android:id="@ id/otp_edit_box4"
                android:layout_width="@dimen/dp_42"
                android:layout_height="@dimen/dp_42"
                android:background="@drawable/edittext_curve_bg"
                android:focusable="true"
                android:focusableInTouchMode="true"
                android:gravity="center"
                android:inputType="numberPassword"
                android:maxLength="1"
                android:textSize="@dimen/sp_30"
                tools:ignore="LabelFor" />
        </LinearLayout>   
        <TextView
            android:id="@ id/tv_preview"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="@dimen/margin_24dp"
            android:drawablePadding="@dimen/dp_10"
            android:text="@string/preview"
            android:textSize="@dimen/sp_20"
            app:drawableStartCompat="@drawable/ic_icon_preview"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@ id/ln_pint_container" />  
        <TextView
            android:id="@ id/btn_next_click"
            style="@style/ButtonStyle"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="@dimen/dp_108"
            android:layout_marginBottom="@dimen/dp_44"
            android:enabled="false"
            android:text="@string/next"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent" />
    </androidx.constraintlayout.widget.ConstraintLayout>

This is my xml i am trying to set btn_next_click in bottom view it showing in bottom in graphical layout but when i try to run it showing middle as you can see below screen in image the button i am trying to keep in bottom parent . can you please help me what mistake i am doing .

enter image description here

CodePudding user response:

Set ConstraintLayout layout_height in the original XML to wrap_content

  • Related