Skip to content

Snappy1

  • Home
  • Android
  • What
  • How
  • Is
  • Can
  • Does
  • Do
  • Why
  • Are
  • Who
  • Toggle search form

[FIXED] android – Right side border of textInputLayout is cropped in alertdialog

Posted on November 11, 2022 By

Solution 1 :

Just use the MaterialAlertDialogBuilder with the same layout:

    MaterialAlertDialogBuilder(context)
            .setTitle("Dialog") 
            .setView(R.layout.password_alert) 
            .setPositiveButton("Ok",  /* listener = */null)
            .setNegativeButton("Cancel",  /* listener = */null)
            .show()

enter image description here

Just a tip: use app:endIconMode="password_toggle" instead of app:passwordToggleEnabled="true"(deprecated)

Problem :

Here is the custom layout password_alert.xml

I have tried increasing the padding in ConstraintLayout. But it still did not work.

<?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"
    android_layout_width="match_parent"
    android_layout_height="match_parent"
    android_padding="15dp">

    <com.google.android.material.textfield.TextInputLayout
        android_id="@+id/til_password"
        style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
        android_layout_width="0dp"
        android_layout_height="wrap_content"
        android_layout_marginStart="8dp"
        android_layout_marginEnd="8dp"
        android_hint="@string/enter_password"
        app_layout_constraintEnd_toEndOf="parent"
        app_layout_constraintStart_toStartOf="parent"
        app_layout_constraintTop_toTopOf="parent"
        app_passwordToggleEnabled="true">

        <com.google.android.material.textfield.TextInputEditText
            android_id="@+id/et_enter_password"
            android_layout_width="match_parent"
            android_layout_height="wrap_content"
            android_inputType="textPassword"
            android_singleLine="true" />
    </com.google.android.material.textfield.TextInputLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

Below is the code for alert dialog

val enterPassDialog = AlertDialog.Builder(this)
        enterPassDialog.setTitle("Password Protected")
        val pass = layoutInflater.inflate(R.layout.enter_password_dialog,null)
        val etPassword = pass.findViewById<EditText>(R.id.et_enter_password)
        enterPassDialog.setView(pass)

        enterPassDialog.setNegativeButton("CANCEL") { dialog, _ ->
            dialog.cancel()
            finish()
        }

        enterPassDialog.setPositiveButton("OK") { _, _ ->

        }

        enterPassDialog.setOnCancelListener { dialog ->

        }

        val enterDialog = enterPassDialog.create()
        enterDialog.show()

I am using Android API 22 as a test device.
Here is the output image –

alert dialog image

Comments

Comment posted by Rajesh kumar

It’s still showing cropped border even after using Material Dialog.

Comment posted by Gabriele Mariotti

@Rajeshkumar only on API 22 or also in other version (try with the emulator)?

READ  [FIXED] android - Baseline Profiles x R8/Proguard
Powered by Inline Related Posts
Android Tags:android, android-alertdialog, android-textinputedittext, android-textinputlayout, kotlin

Post navigation

Previous Post: [FIXED] Problem with the implementation of the Android Studio Java design libraries
Next Post: [FIXED] android – Kotlin: Typeconverter for other class type

Related Posts

[FIXED] android – Can not read image with BitmapFactory.decodeFile Android
[FIXED] Android Q, Touch screen does not scale after resolution changed Android
[FIXED] xamarin.forms – Java.Lang.NullPointerException: Attempt to invoke virtual method ‘void com.google.firebase.auth.FirebaseAuth.zza Android
[FIXED] java – Can’t get Android text to speech to read on start of an activity without a button using a text or JSon file Android
[FIXED] java – How to convert Address type of Barcode.CONTACT_INFO To String Type in Android? Android
[FIXED] android – How do i open a fragment from an onClickListener inside a fragment in kotlin? Android

Archives

  • April 2023
  • March 2023
  • February 2023
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022

Categories

  • ¿Cómo
  • ¿Cuál
  • ¿Cuándo
  • ¿Cuántas
  • ¿Cuánto
  • ¿Qué
  • Android
  • Are
  • At
  • C'est
  • Can
  • Comment
  • Did
  • Do
  • Does
  • Est-ce
  • Est-il
  • For
  • Has
  • Hat
  • How
  • In
  • Is
  • Ist
  • Kann
  • Où
  • Pourquoi
  • Quand
  • Quel
  • Quelle
  • Quelles
  • Quels
  • Qui
  • Should
  • Sind
  • Sollte
  • Uncategorized
  • Wann
  • Warum
  • Was
  • Welche
  • Welchen
  • Welcher
  • Welches
  • Were
  • What
  • What's
  • When
  • Where
  • Which
  • Who
  • Who's
  • Why
  • Wie
  • Will
  • Wird
  • Wo
  • Woher
  • you can create a selvedge edge: You can make the edges of garter stitch more smooth by slipping the first stitch of every row.2022-02-04
  • you really only need to know two patterns: garter stitch

Recent Posts

  • Can Vicks humidifier be used without filter?
  • What color is Spanish green?
  • How old is Jamie in The War That Saved My Life?
  • When should I use scalp massager for hair growth?
  • Can I put polyurethane over liming wax?

Recent Comments

No comments to show.

Copyright © 2023 Snappy1.

Powered by PressBook Grid Dark theme