how fixed “text hint” in TextInputLayout?How to save an Android Activity state using save instance state?How do I center text horizontally and vertically in a TextView?Why is the Android emulator so slow? How can we speed up the Android emulator?Place cursor at the end of text in EditTextHow do I fix android.os.NetworkOnMainThreadException?Android sdk 18 TextView gravity doesn't work verticallyAndroid: how to place the text of a textview in the middle of its parentTextInputLayout not showing EditText hint before user focus on itDisable Tabs in TabLayoutTextInputLayout: Different color for hint label when not focused

How would modern naval warfare have to have developed differently for battleships to still be relevant in the 21st century?

Wifi dongle speed is slower than advertised

Swapping rooks in a 4x4 board

How does a blind passenger not die, if driver becomes unconscious

Should my manager be aware of private LinkedIn approaches I receive? How to politely have this happen?

Can any NP-Complete Problem be solved using at most polynomial space (but while using exponential time?)

If you snatch, I trade

Accidentals and ties

How dangerous are set-size assumptions?

Can Ogre clerics use Purify Food and Drink on humanoid characters?

Is it damaging to turn off a small fridge for two days every week?

Has there been any indication at all that further negotiation between the UK and EU is possible?

What's currently blocking the construction of the wall between Mexico and the US?

How can I politely work my way around not liking coffee or beer when it comes to professional networking?

Why do some games show lights shine thorugh walls?

Is a single radon-daughter atom in air a solid?

C-152 carb heat on before landing in hot weather?

How to create a Tetrix/Sierpinski Tetrahedron fractal radiating from 0,0,0 ? Python or nodes

What are the penalties for overstaying in USA?

Did Karl Marx ever use any example that involved cotton and dollars to illustrate the way capital and surplus value were generated?

I am completely new to Tales from the Floating Vagabond, how do I get started?

Why the feminine "la" in "à la Leonardo DiCaprio", though he is a man?

Why doesn't a marching band have strings?

Cascading Repair Costs following Blown Head Gasket on a 2004 Subaru Outback



how fixed “text hint” in TextInputLayout?


How to save an Android Activity state using save instance state?How do I center text horizontally and vertically in a TextView?Why is the Android emulator so slow? How can we speed up the Android emulator?Place cursor at the end of text in EditTextHow do I fix android.os.NetworkOnMainThreadException?Android sdk 18 TextView gravity doesn't work verticallyAndroid: how to place the text of a textview in the middle of its parentTextInputLayout not showing EditText hint before user focus on itDisable Tabs in TabLayoutTextInputLayout: Different color for hint label when not focused






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















I need to use "errorValidation" and "hint" in TextInputLayout.
I want to fixed hint in TextInputLayout that it does not go to the label of my TextInputLayout.
Actually, I want the hint to be as a label at first.



in other words:
I use the hint as TextView for the label of TextInputLayout but the problem is too much margin !!!
how can I handle this?



the attached picture define how I use TextView for the label of TextInputLayout.



enter image description here



the code I used:



<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/tv_label_previous_password"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/toolbar_change_password"
android:layout_marginTop="@dimen/spacing_5x"
android:layout_marginStart="@dimen/spacing_3x"
android:text="@string/label_previous_password"
style="@style/TextHintYekanRegularHintColor16" />

<com.google.android.material.textfield.TextInputLayout
android:id="@+id/til_previous_password"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="@id/tv_label_previous_password"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:layout_marginStart="@dimen/spacing_3x"
android:layout_marginEnd="@dimen/spacing_3x"
style="@style/TextInputLayoutAppearance" >

<com.google.android.material.textfield.TextInputEditText
android:id="@+id/et_previous_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/TextYekanRegularColorPurpleOne16"
android:inputType="textPassword" />

</com.google.android.material.textfield.TextInputLayout>









share|improve this question






























    1















    I need to use "errorValidation" and "hint" in TextInputLayout.
    I want to fixed hint in TextInputLayout that it does not go to the label of my TextInputLayout.
    Actually, I want the hint to be as a label at first.



    in other words:
    I use the hint as TextView for the label of TextInputLayout but the problem is too much margin !!!
    how can I handle this?



    the attached picture define how I use TextView for the label of TextInputLayout.



    enter image description here



    the code I used:



    <androidx.appcompat.widget.AppCompatTextView
    android:id="@+id/tv_label_previous_password"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintTop_toBottomOf="@id/toolbar_change_password"
    android:layout_marginTop="@dimen/spacing_5x"
    android:layout_marginStart="@dimen/spacing_3x"
    android:text="@string/label_previous_password"
    style="@style/TextHintYekanRegularHintColor16" />

    <com.google.android.material.textfield.TextInputLayout
    android:id="@+id/til_previous_password"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    app:layout_constraintTop_toBottomOf="@id/tv_label_previous_password"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    android:layout_marginStart="@dimen/spacing_3x"
    android:layout_marginEnd="@dimen/spacing_3x"
    style="@style/TextInputLayoutAppearance" >

    <com.google.android.material.textfield.TextInputEditText
    android:id="@+id/et_previous_password"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    style="@style/TextYekanRegularColorPurpleOne16"
    android:inputType="textPassword" />

    </com.google.android.material.textfield.TextInputLayout>









    share|improve this question


























      1












      1








      1








      I need to use "errorValidation" and "hint" in TextInputLayout.
      I want to fixed hint in TextInputLayout that it does not go to the label of my TextInputLayout.
      Actually, I want the hint to be as a label at first.



      in other words:
      I use the hint as TextView for the label of TextInputLayout but the problem is too much margin !!!
      how can I handle this?



      the attached picture define how I use TextView for the label of TextInputLayout.



      enter image description here



      the code I used:



      <androidx.appcompat.widget.AppCompatTextView
      android:id="@+id/tv_label_previous_password"
      android:layout_width="0dp"
      android:layout_height="wrap_content"
      app:layout_constraintStart_toStartOf="parent"
      app:layout_constraintEnd_toEndOf="parent"
      app:layout_constraintTop_toBottomOf="@id/toolbar_change_password"
      android:layout_marginTop="@dimen/spacing_5x"
      android:layout_marginStart="@dimen/spacing_3x"
      android:text="@string/label_previous_password"
      style="@style/TextHintYekanRegularHintColor16" />

      <com.google.android.material.textfield.TextInputLayout
      android:id="@+id/til_previous_password"
      android:layout_width="0dp"
      android:layout_height="wrap_content"
      app:layout_constraintTop_toBottomOf="@id/tv_label_previous_password"
      app:layout_constraintStart_toStartOf="parent"
      app:layout_constraintEnd_toEndOf="parent"
      android:layout_marginStart="@dimen/spacing_3x"
      android:layout_marginEnd="@dimen/spacing_3x"
      style="@style/TextInputLayoutAppearance" >

      <com.google.android.material.textfield.TextInputEditText
      android:id="@+id/et_previous_password"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      style="@style/TextYekanRegularColorPurpleOne16"
      android:inputType="textPassword" />

      </com.google.android.material.textfield.TextInputLayout>









      share|improve this question
















      I need to use "errorValidation" and "hint" in TextInputLayout.
      I want to fixed hint in TextInputLayout that it does not go to the label of my TextInputLayout.
      Actually, I want the hint to be as a label at first.



      in other words:
      I use the hint as TextView for the label of TextInputLayout but the problem is too much margin !!!
      how can I handle this?



      the attached picture define how I use TextView for the label of TextInputLayout.



      enter image description here



      the code I used:



      <androidx.appcompat.widget.AppCompatTextView
      android:id="@+id/tv_label_previous_password"
      android:layout_width="0dp"
      android:layout_height="wrap_content"
      app:layout_constraintStart_toStartOf="parent"
      app:layout_constraintEnd_toEndOf="parent"
      app:layout_constraintTop_toBottomOf="@id/toolbar_change_password"
      android:layout_marginTop="@dimen/spacing_5x"
      android:layout_marginStart="@dimen/spacing_3x"
      android:text="@string/label_previous_password"
      style="@style/TextHintYekanRegularHintColor16" />

      <com.google.android.material.textfield.TextInputLayout
      android:id="@+id/til_previous_password"
      android:layout_width="0dp"
      android:layout_height="wrap_content"
      app:layout_constraintTop_toBottomOf="@id/tv_label_previous_password"
      app:layout_constraintStart_toStartOf="parent"
      app:layout_constraintEnd_toEndOf="parent"
      android:layout_marginStart="@dimen/spacing_3x"
      android:layout_marginEnd="@dimen/spacing_3x"
      style="@style/TextInputLayoutAppearance" >

      <com.google.android.material.textfield.TextInputEditText
      android:id="@+id/et_previous_password"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      style="@style/TextYekanRegularColorPurpleOne16"
      android:inputType="textPassword" />

      </com.google.android.material.textfield.TextInputLayout>






      android material-design






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 25 at 12:32









      Fábio Nascimento

      1,54514 silver badges19 bronze badges




      1,54514 silver badges19 bronze badges










      asked Mar 25 at 9:36









      Abolfazl KalamatiAbolfazl Kalamati

      19410 bronze badges




      19410 bronze badges






















          1 Answer
          1






          active

          oldest

          votes


















          1














          You can solve margin problem of TextInputLayout with two tricks. You have used one trick that use a normal EditText instead of hint. Then you must set



          app:hintEnabled="false"


          to remove the margin on top of your TextInputLayout.



          Second trick is that you should enable error for TextInputLayout in your fragment or activity instead of the layout file. This will remove the margin in the bottom of TextInputLayout. And when error is gone you should disable error for TextInputLayout. This code will do the trick for you:



          your_text_input_layout.isErrorEnabled = true // to enable the error
          your_text_input_layout.isErrorEnabled = false // to disable the error





          share|improve this answer

























            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55334847%2fhow-fixed-text-hint-in-textinputlayout%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1














            You can solve margin problem of TextInputLayout with two tricks. You have used one trick that use a normal EditText instead of hint. Then you must set



            app:hintEnabled="false"


            to remove the margin on top of your TextInputLayout.



            Second trick is that you should enable error for TextInputLayout in your fragment or activity instead of the layout file. This will remove the margin in the bottom of TextInputLayout. And when error is gone you should disable error for TextInputLayout. This code will do the trick for you:



            your_text_input_layout.isErrorEnabled = true // to enable the error
            your_text_input_layout.isErrorEnabled = false // to disable the error





            share|improve this answer



























              1














              You can solve margin problem of TextInputLayout with two tricks. You have used one trick that use a normal EditText instead of hint. Then you must set



              app:hintEnabled="false"


              to remove the margin on top of your TextInputLayout.



              Second trick is that you should enable error for TextInputLayout in your fragment or activity instead of the layout file. This will remove the margin in the bottom of TextInputLayout. And when error is gone you should disable error for TextInputLayout. This code will do the trick for you:



              your_text_input_layout.isErrorEnabled = true // to enable the error
              your_text_input_layout.isErrorEnabled = false // to disable the error





              share|improve this answer

























                1












                1








                1







                You can solve margin problem of TextInputLayout with two tricks. You have used one trick that use a normal EditText instead of hint. Then you must set



                app:hintEnabled="false"


                to remove the margin on top of your TextInputLayout.



                Second trick is that you should enable error for TextInputLayout in your fragment or activity instead of the layout file. This will remove the margin in the bottom of TextInputLayout. And when error is gone you should disable error for TextInputLayout. This code will do the trick for you:



                your_text_input_layout.isErrorEnabled = true // to enable the error
                your_text_input_layout.isErrorEnabled = false // to disable the error





                share|improve this answer













                You can solve margin problem of TextInputLayout with two tricks. You have used one trick that use a normal EditText instead of hint. Then you must set



                app:hintEnabled="false"


                to remove the margin on top of your TextInputLayout.



                Second trick is that you should enable error for TextInputLayout in your fragment or activity instead of the layout file. This will remove the margin in the bottom of TextInputLayout. And when error is gone you should disable error for TextInputLayout. This code will do the trick for you:



                your_text_input_layout.isErrorEnabled = true // to enable the error
                your_text_input_layout.isErrorEnabled = false // to disable the error






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 28 at 6:28









                MaHDiMaHDi

                1027 bronze badges




                1027 bronze badges





























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55334847%2fhow-fixed-text-hint-in-textinputlayout%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                    Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

                    Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript