GithubHelp home page GithubHelp logo

hitgif / textfieldboxes Goto Github PK

View Code? Open in Web Editor NEW
772.0 27.0 115.0 2.01 MB

Material Design text field that comes in a box, based on (OLD) Google Material Design guidelines.

License: Apache License 2.0

Java 100.00%
android library java edittext material material-design component-library icon-signifier label-text dark-theme

textfieldboxes's Introduction

TextFieldBoxes

Build Status JitPack Android Arsenal API GitHub issues GitHub forks GitHub stars GitHub license

Animation

A new Material Design text field that comes in a box, based on Google Material Design guidelines.

🇨🇳 中文看这里

Buy Me a Coffee at ko-fi.com

UPDATE NOTICE

1.4.5 Release

  • Fix attr/counterTextColor name conflict (#97 #99 #105). The counterTextColor property is now renamed to mCounterTextColor.

1.4.4 Release

  • Layout updated to support bigger clear icon and end icons (#72).

1.4.3 Release

Requirements

  • Android 4.0.3 IceCreamSandwich (API lv 15) or greater
  • Your favorite IDE

Installation

In order to use it, you need to include it in your project.

Gradle:

allprojects {
    repositories {
      ...
      maven { url 'https://jitpack.io' }
    }
}
dependencies {
    compile 'com.github.HITGIF:TextFieldBoxes:1.4.5'
}

Maven:

<repositories>
    <repository>
         <id>jitpack.io</id>
         <url>https://jitpack.io</url>
    </repository>
</repositories>
<dependency>
    <groupId>com.github.HITGIF</groupId>
    <artifactId>TextFieldBoxes</artifactId>
    <version>1.4.5</version>
</dependency>

SBT:

resolvers += "jitpack" at "https://jitpack.io"
libraryDependencies += "com.github.HITGIF" % "TextFieldBoxes" % "1.4.5"

Leiningen:

:repositories [["jitpack" "https://jitpack.io"]]
:dependencies [[com.github.hitgif/textfieldboxes "1.4.5"]]

Usage

Table of Contents

  1. Basic
  2. Enable / Disable
  3. Helper Text & Error Text
  4. Prefix & Suffix
  5. Max & Min Characters
  6. Icon Signifier
  7. End Icon
  8. Clear Button
  9. Custom Colors
  10. Dense Spacing
  11. Always Show Hint
  12. Text Change Watcher
  13. Dark Theme
  14. Manual Validate Error

Add studio.carbonylgroup.textfieldboxes.TextFieldBoxes that contains a studio.carbonylgroup.textfieldboxes.ExtendedEditText to your layout:

...
<studio.carbonylgroup.textfieldboxes.TextFieldBoxes
    android:id="@+id/text_field_boxes"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:labelText="Label"
    >

    <studio.carbonylgroup.textfieldboxes.ExtendedEditText
        android:id="@+id/extended_edit_text"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        />

</studio.carbonylgroup.textfieldboxes.TextFieldBoxes>
...

NOTE that app:labelText is optional from release 1.3.6.

app:enabled in xml or setEnabled(boolean enabled) in Java.

<studio.carbonylgroup.textfieldboxes.TextFieldBoxes
    ...
    app:enabled="false"
    >

NOTE: setting helper or error text to anything not empty will make the bottom view (which contains the helper label) visible and increase the height of the TextFieldBoxes. So if you want to always keep the bottom view visible (height increased), set the helper text to " " when there should be nothing.

helper text: app:helperText in xml or setHelperText(String helperText) in Java.

<studio.carbonylgroup.textfieldboxes.TextFieldBoxes
    ...
    app:helperText="Helper is here"
    >

error text: setError(String errorText, boolean giveFocus) in Java.

Param giveFocus determines whether the field will gain focus when set error on. If true, the field gains focus immediately.

NOTE: Error will be removed when the text changes (input or delete).

setError("Error message");

! NOTE: Prifix and Suffix attributes should be set to ExtendedEditText.

Use app:prefix in xml or setPrefix(String prefix) in Java to set the unselectable prefix text at the start of the field.

Use app:suffix in xml or setSuffix(String suffix) in Java to set the unselectable suffix text at the end of the field.

<studio.carbonylgroup.textfieldboxes.ExtendedEditText
    ...
    app:prefix="$ "
    >

<studio.carbonylgroup.textfieldboxes.ExtendedEditText
    ...
    app:suffix="\@gmail.com"
    >

NOTE: setting max or min character will make the bottom view (which contains the counter label) visible and increase the height of the TextFieldBoxes.

Use app:maxCharacters in xml or setMaxCharacters(int maxCharacters) in java code to set the max characters count. Use removeMaxCharacters() in java code to remove the limit.

Use app:minCharacters in xml or setMinCharacters(int minCharacters) in java code to set the min characters count. Use removeMinCharacters() in java code to remove the limit.

The color of the bottom line will turn to errorColor (red by default) when exceeding max or min characters limit. 0, as default, means no max or min characters limit.

NOTE: Space and line feed will NOT count.

<studio.carbonylgroup.textfieldboxes.TextFieldBoxes
    ...
    app:maxCharacters="10"
    app:minCharacters="5"
    >

<studio.carbonylgroup.textfieldboxes.TextFieldBoxes
    ...
    app:maxCharacters="5"
    >

Use app:iconSignifier in xml or setIconSignifier(Int resourceID) to set the icon that is shown in front of the TextFieldBoxes if you want there to be one.

You can use setIsResponsiveIconColor(boolean isrResponsiveIconColor) in Java code to set whether the icon will change its color when gaining or losing focus as the label text and the bottomLine do. NOTE that if true, the icon's color will always be HighlightColor (the same as the bottomLine) that will turn gray when losing focus. If false, the icon will always be in primaryColor.

<studio.carbonylgroup.textfieldboxes.TextFieldBoxes
    ...
    app:iconSignifier="@drawable/ic_vpn_key_black_24dp"
    >

Use app:endIcon in xml or setEndIcon(Int resourceID) to set the icon of the ImageButton that is shown at the end of the field if you want there to be one.

<studio.carbonylgroup.textfieldboxes.TextFieldBoxes
    ...
    app:endIcon="@drawable/ic_mic_black_24dp"
    >

To make it useful (trigger voice input, dropdown event), you would like to use getEndIconImageButton() in Java code to set, for example, what will happen when it's clicked (with .setOnClickListener()), or anything else you want.

final TextFieldBoxes textFieldBoxes = findViewById(R.id.text_field_boxes);
textFieldBoxes.getEndIconImageButton().setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
        // What you want to do when it's clicked
    }
});

Use app:hasClearButton in xml or setHasClearButton(boolean hasClearButton) to set whether to show the clear button.

If true, a clear button will be shown at the end when there are characters (ANY character) entered in the field.

<studio.carbonylgroup.textfieldboxes.TextFieldBoxes
    ...
    app:hasClearButton="true"
    >

Primary Color will be used for the color of the underline, the floating label text and the icon signifier when HAVING focus. You can use app:primaryColor in xml or setPrimaryColor(int colorRes) in Java. Current theme Primary Color by default.

Secondary Color will be used for the color of the underline, the floating label text and the icon signifier when NOT HAVING focus. You can use app:secondaryColor in xml or setSecondaryColor(int colorRes) in Java. Current theme textColorTertiary by default.

Error Color will be used for the color that indicates error (e.g. exceeding max characters, setError()). You can use app:errorColor in xml or setErrorColor(int colorRes) in Java. A400 red by default.

Helper Text Color will be used for the color of the helper text. You can use app:helperTextColor in xml or setHelperTextColor(int colorRes) in Java. 54% black by default.

Panel Background Color will be used for the color of panel at the back. You can use app:panelBackgroundColor in xml or setPanelBackgroundColor(int colorRes) in Java. 6% black by default. NOTE that the default color, as in the guideline, is the black (#000000) color with the transparency of 6%, so when you're customizing and want it to still be transparent you have to set a color with transparency.

<studio.carbonylgroup.textfieldboxes.TextFieldBoxes
    ...
    app:primaryColor="#1B5E20"
    app:errorColor="#ddaa00"
    app:helperTextColor="#795548"
    app:panelBackgroundColor="#ffe8e8"
    >

Ripple Color will be used for the ripple effect when the view is clicked. You can customize it in your styles.xml by adding the following:

<style name="TextFieldBoxes">
    <item name="android:colorControlHighlight" tools:targetApi="lollipop">YOUR_COLOR</item>
</style>

then set this as the theme for your TextFieldBoxes:

<studio.carbonylgroup.textfieldboxes.TextFieldBoxes
    ...
    android:theme="@style/TextFieldBoxes"
    >

You can make the layout compact by using a dense verticle spacing to improve user experience in some cases.

Use app:useDenseSpacing in xml or setUseDenseSpacing(boolean useDenseSpacing) to set whether the field uses a dense spacing between its elements.

<studio.carbonylgroup.textfieldboxes.TextFieldBoxes
    ...
    app:useDenseSpacing="true"
    >

Sometimes you may want the label and the hint to show different messages, but need the hint to always be shown (instead being blocked by the label when losing focus).

Use app:alwaysShowHint in xml or setAlwaysShowHint(boolean alwaysShowHint) to set whether the label is fixed at top when there's a hint in the EditText.

<studio.carbonylgroup.textfieldboxes.TextFieldBoxes
    ...
    app:alwaysShowHint="true"
    >

It is strongly recommanded to use setSimpleTextChangeWatcher() to listen the event of changing text instead of addTextChangedListener().

This has the following advantages:

  1. You don't need to implement beforeTextChanged() and onTextChanged() method when unnecessary.
  2. Avoids potential unexpected behavior, by guaranteeing your code to run after the default processes (remove error, update counter text, etc.) are finished.
  3. When the view is recycled, no manual remove call is needed.

e.g.

final TextFieldBoxes textFieldBoxes = findViewById(R.id.text_field_boxes);
textFieldBoxes.setSimpleTextChangeWatcher(new SimpleTextChangedWatcher() {
    @Override
    public void onTextChanged(String theNewText, boolean isError) {
        // What you want to do when text changes
    }
});

TextFieldBoxes use the color attributes within the current theme and will automatically change its color to fit the dark theme without additional settings.

By default, the error state of the field is validated each time the text changes and also at time of construction. This means a field with a minimum length requirement will start in the Error state.

Setting app:manualValidateError to true will make the field validate error only when validate() is called.

<studio.carbonylgroup.textfieldboxes.TextFieldBoxes
    ...
    app:manualValidateError="true"
    >
final TextFieldBoxes textFieldBoxes = findViewById(R.id.text_field_boxes);
// The error state will only be updated when this is called
textFieldBoxes.validate()

All Attributes

ExtendedEditText

Texts
Attribute Description
app:prefix Prefix Text
app:suffix Suffix Text
Colors
Attribute Description Default
app:prefixTextColor Prefix text color Current theme textColorTertiary
app:suffixTextColor Suffix text color Current theme textColorTertiary

TextFieldBoxes

Texts
Attribute Description
app:labelText Floating label text at the top
app:helperText Helper text at the bottom
Colors
Attribute Description Default
app:helperTextColor Helper text color Current theme textColorTertiary
app:mCounterTextColor Counter text color Current theme textColorTertiary
app:errorColor The color that is used to indicate error (e.g. exceeding max characters, setError()) A400 red
app:primaryColor The color for the underline, the floating label text and the icon signifier when HAVING FOCUS Current theme colorPrimary
app:secondaryColor The color for the underline, the floating label text and the icon signifier when NOT HAVING FOCUS Current theme textColorTertiary
app:panelBackgroundColor The color for the panel at the back 6% Current theme colorForeground
Icons
Attribute Description Default
app:iconSignifier The resource ID of the icon before the TextFieldBoxes 0
app:endIcon The resource ID of the icon at the end of the field 0
app:isResponsiveIconColor whether the icon signifier will change its color when gaining or losing focus as the label and the bottomLine do True
Characters counter
Attribute Description Default
app:maxCharacters Max characters count limit. 0 means no limit 0
app:minCharacters Min characters count limit. 0 means no limit 0
Others
Attribute Description Default
app:enabled Whether the text field is enabled True
app:hasClearButton Whether to show the clear button at the end of the EditText False
app:hasFocus Whether the EditText is having the focus False
app:alwaysShowHint Whether the label is fixed at top when there's a hint in the EditText False
app:useDenseSpacing Whether the field uses a dense spacing between its elements False
app:manualValidateError Whether to validate error state only when validate() is called False

License

Copyright 2020 Mark Wang

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

textfieldboxes's People

Contributors

erdalceylan avatar frankdomburg avatar hitgif avatar imprakharshukla avatar newcolours avatar rakesh1988 avatar raunak-many-ac avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

textfieldboxes's Issues

Remove <application> from AndroidManifest.xml

Since TextFieldBoxes is a library, it should not have an element in the AndroidManifest.xml file. This actually causes it to interfere with attributes in a real application's AndroidManifest.xml file.

Thanks!

Issues with layout

<studio.carbonylgroup.textfieldboxes.TextFieldBoxes
    android:id="@+id/text_field_boxes"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@id/image_logo"
    android:layout_marginEnd="@dimen/activity_horizontal_margin"
    android:layout_marginStart="@dimen/activity_horizontal_margin"
    app:errorColor="@color/nc_white_color_complete"
    app:helperText=" "
    app:labelText="@string/nc_server_url"
    app:panelBackgroundColor="@color/colorPrimary"
    app:primaryColor="@color/nc_white_color_complete">

    <studio.carbonylgroup.textfieldboxes.ExtendedEditText
        android:id="@+id/extended_edit_text"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:imeOptions="actionDone"
        android:inputType="textUri"
        android:minWidth="5dp"
        android:singleLine="true"
        android:textColor="@color/nc_white_color_complete"/>

</studio.carbonylgroup.textfieldboxes.TextFieldBoxes>

screen shot 2018-01-25 at 15 29 36
screen shot 2018-01-25 at 15 30 02

One is Android 6. One is Android 7. Notice how on 6 the TextFieldBoxes takes entire height despite being set to wrap_content :-/

Error:(252, 5) error: duplicate value for resource 'attr/helperTextColor' with config ''.

C:\Users\qwe.gradle\caches\transforms-1\files-1.1\appcompat-v7-27.0.2.aar\7cf6837638c36c9f6ecfbeb693286dca\res\values\values.xml
Error:(252, 5) error: duplicate value for resource 'attr/helperTextColor' with config ''.
Error:(252, 5) error: resource previously defined here.

AGPBI: {"kind":"error","text":"error: duplicate value for resource \u0027attr/helperTextColor\u0027 with config \u0027\u0027.","sources":[{"file":"C:\Users\qwe\.gradle\caches\transforms-1\files-1.1\appcompat-v7-27.0.2.aar\7cf6837638c36c9f6ecfbeb693286dca\res\values\values.xml","position":{"startLine":251,"startColumn":4,"startOffset":27028,"endColumn":68,"endOffset":27092}}],"original":"","tool":"AAPT"}
AGPBI: {"kind":"error","text":"error: resource previously defined here.","sources":[{"file":"C:\Users\qwe\.gradle\caches\transforms-1\files-1.1\appcompat-v7-27.0.2.aar\7cf6837638c36c9f6ecfbeb693286dca\res\values\values.xml","position":{"startLine":251,"startColumn":4,"startOffset":27028,"endColumn":68,"endOffset":27092}}],"original":"","tool":"AAPT"}

Cursor is not visible

Hi, this is the setup I have and the cursor is not visible.

<studio.carbonylgroup.textfieldboxes.TextFieldBoxes
                            android:id="@+id/tfb_user_id"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            app:labelText="@string/hint_user_id">

                            <studio.carbonylgroup.textfieldboxes.ExtendedEditText
                                android:id="@+id/et_user_id"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:inputType="text"/>

                        </studio.carbonylgroup.textfieldboxes.TextFieldBoxes>

Incompatibility with AAPT2 ( Failed to execute aapt )

I just followed the installation guide and I got it ...

This is my output:

C:\Users\fabio.filho.gradle\caches\transforms-1\files-1.1\design-27.0.1.aar\2609d08221b55d3c670f82da34939204\res\values-v26\values-v26.xml
Error:(3, 5) error: style attribute 'android:attr/keyboardNavigationCluster' not found.
C:\Users\fabio.filho.gradle\caches\transforms-1\files-1.1\appcompat-v7-27.0.1.aar\0a0cdf826e5f18c37293193437afa365\res\values-v26\values-v26.xml
Error:(9, 5) error: resource android:attr/colorError not found.
Error:(13, 5) error: resource android:attr/colorError not found.
Error:(17, 5) error: style attribute 'android:attr/keyboardNavigationCluster' not found.
C:\Users\fabio.filho.gradle\caches\transforms-1\files-1.1\appcompat-v7-27.0.1.aar\0a0cdf826e5f18c37293193437afa365\res\values\values.xml
Error:(252, 5) error: resource android:attr/keyboardNavigationCluster not found.
Error:(252, 5) error: resource android:attr/fontStyle not found.
Error:(252, 5) error: resource android:attr/font not found.
Error:(252, 5) error: resource android:attr/fontWeight not found.
C:\Users\fabio.filho\Documents\Docs\Repositories\MyProject\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values-v26\values-v26.xml
Error:(7) resource android:attr/colorError not found.
Error:(11) resource android:attr/colorError not found.
Error:(15) style attribute 'android:attr/keyboardNavigationCluster' not found.
Error:(18) style attribute 'android:attr/keyboardNavigationCluster' not found.
C:\Users\fabio.filho\Documents\Docs\Repositories\MyProject\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml
Error:(359) resource android:attr/keyboardNavigationCluster not found.
Error:(602) resource android:attr/fontStyle not found.
Error:(602) resource android:attr/font not found.
Error:(602) resource android:attr/fontWeight not found.
Error:failed linking references.
Error:java.util.concurrent.ExecutionException: java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:org.gradle.tooling.BuildException: Failed to execute aapt
Error:com.android.ide.common.process.ProcessException: Failed to execute aapt
Error:java.util.concurrent.ExecutionException: java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details

setOnClickListener is not working on TextFieldBoxes and ExtendedEditText

TextFieldBoxes.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Log.i("LOG","ive been clicked");
            }
        });

ExtendedEditText.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Log.i("LOG","ive been clicked");
            }
        });

can you help me?

Adding a TextWatcher on ExtendedEditText causes infinite Loop crash with setError

I attached a textWatcher onto the ExtendedEditText, and whenever the text is empty, it calls setError()

but calling setError causes the TextWatcher to be triggered and since the text is empty ic calls setError()

but that triggers the TextWatcher again and since its still empty it calls setError()

but the TextWatcher is triggered again. I cannot have a reactive layout like that, is this intentional?

Will not compile after including the library

After including the library in Android Studio 2.3, targeting SDK 25 by:

allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
dependencies {
compile 'com.github.HITGIF:TextFieldBoxes:1.3.8'
}

I got the following error:

Error:(754) Multiple substitutions specified in non-positional format; did you mean to add the formatted="false" attribute?

which references a string resource:

%s%s%s%s

I THINK the correct way to do this, is either to set formated=false for this string, or specify in the way: %1$s%2$s%3$s%4$s.

Are you open for suggestions?

I'm using a very good lib for EditText with label - but it's not maintained anymore.
So I'm searching for a replacement.

Use another text widget, for example AutoCompleteTextView

Thanks for your lib, it's really great to have it.

I would like to know how I could use it for autocomplete text views? I tried to wrap one inside a TextFieldBoxes but this fails:

Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.TextView.setText(java.lang.CharSequence)' on a null object reference
    at studio.carbonylgroup.textfieldboxes.TextFieldBoxes.setLabelText(TextFieldBoxes.java:748)
    at studio.carbonylgroup.textfieldboxes.TextFieldBoxes.triggerSetters(TextFieldBoxes.java:718)
    at studio.carbonylgroup.textfieldboxes.TextFieldBoxes.onFinishInflate(TextFieldBoxes.java:224)

I'm guessing I can't put any widget I want there. Is there a way I could hack this in?
Thanks

Unable to import library

How can anyone help me?
@HITGIF

compile 'com.android.support:appcompat-v7:26.1.0'
compile 'com.android.support:support-v4:26.+'

compileSdkVersion 26
buildToolsVersion "26.0.0"
defaultConfig {
applicationId "***"
minSdkVersion 15
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}

Error:Execution failed for task ':app:processDebugManifest'.

Manifest merger failed : Attribute meta-data#android.support.VERSION@value value=(26.0.1) from [com.android.support:design:26.0.1] AndroidManifest.xml:28:13-35
is also present at [com.android.support:appcompat-v7:26.1.0] AndroidManifest.xml:28:13-35 value=(26.1.0).
Suggestion: add 'tools:replace="android:value"' to element at AndroidManifest.xml:26:9-28:38 to override.

android.graphics.drawable.BitmapDrawable cannot be cast to android.graphics.drawable.LayerDrawable

Hello,
I try to use this code in my xml code.

<studio.carbonylgroup.textfieldboxes.TextFieldBoxes
    android:id="@+id/fg_save_as_file_container"

    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:labelText="@string/lbl_filename_without_ext"
    app:helperText="@string/lbl_filename_limit_desc"
    app:hasClearButton="true"
    app:minCharacters="2"
    app:maxCharacters="128"
    >

    <studio.carbonylgroup.textfieldboxes.ExtendedEditText
        android:id="@+id/fg_save_as_file_filename"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:maxLines="1"
        android:singleLine="true"
        android:text="" />

</studio.carbonylgroup.textfieldboxes.TextFieldBoxes>

And I got this error.

FATAL EXCEPTION: main
Process: net.sjava.docs, PID: 8749
java.lang.RuntimeException: Unable to start activity ComponentInfo{net.sjava.docs/net.sjava.docs.ui.activities.MainActivity}: android.view.InflateException: Binary XML file line #82: android.graphics.drawable.BitmapDrawable cannot be cast to android.graphics.drawable.LayerDrawable
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2947)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3008)
at android.app.ActivityThread.-wrap14(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1650)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6688)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1468)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1358)
Caused by: android.view.InflateException: Binary XML file line #82: android.graphics.drawable.BitmapDrawable cannot be cast to android.graphics.drawable.LayerDrawable
Caused by: java.lang.ClassCastException: android.graphics.drawable.BitmapDrawable cannot be cast to android.graphics.drawable.LayerDrawable
at studio.carbonylgroup.textfieldboxes.TextFieldBoxes.setPanelBackgroundColor(TextFieldBoxes.java:697)
at studio.carbonylgroup.textfieldboxes.TextFieldBoxes.onFinishInflate(TextFieldBoxes.java:285)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:879)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:828)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:873)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:828)
at android.view.LayoutInflater.inflate(LayoutInflater.java:525)
at android.view.LayoutInflater.inflate(LayoutInflater.java:427)
at android.view.LayoutInflater.inflate(LayoutInflater.java:378)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)

Change size of the Label text

Sometimes the size of the label text is too big and take two lines so when the edit text has the focus it animate to the top it still taking two lines but now there are enough space to fill it in one line

How to make a label be always on top?

I have a hint in the EditText and a label in his Box view. And I want both of them (hint and label) be visible if no text inputed regardless the view focus state.
Is it possible?

Suggestion: Dropdown icon and callback

If you're taking suggestions, I'd love it if there was an option to display a dropdown icon and the ability to set a callback for when it is clicked. I think the callback should include a reference to the TextFieldBox. I do not think it's necessary for the TextFieldBox to do more than this and the developer can handle what happens when it's clicked. For example, I would probably use a ListPopupWindow to display and select options.

FATAL EXCEPTION api level 15 UnsupportedOperationException

FATAL EXCEPTION: main
java.lang.UnsupportedOperationException
at android.view.GLES20Canvas.clipPath(GLES20Canvas.java:424)
at studio.carbonylgroup.textfieldboxes.ClipToBoundsView.onDraw(ClipToBoundsView.java:55)
at android.view.View.draw(View.java:11038)

java.lang.IllegalStateException: Circular dependencies cannot exist in RelativeLayout

I got this errors from Android 4.x to Android 5.0.2.
I can't represent, but I would like to report this crash issue.

Fatal Exception: java.lang.IllegalStateException: Circular dependencies cannot exist in RelativeLayout
at android.widget.RelativeLayout$DependencyGraph.getSortedViews(RelativeLayout.java:1531)
at android.widget.RelativeLayout.sortChildren(RelativeLayout.java:343)
at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:363)
at android.view.View.measure(View.java:16482)
at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:437)
at android.view.View.measure(View.java:16482)
at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:437)
at android.view.View.measure(View.java:16482)
at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:437)
at android.view.View.measure(View.java:16482)
at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:681)
at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:461)
at android.view.View.measure(View.java:16482)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5055)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
at studio.carbonylgroup.textfieldboxes.TextFieldBoxes.onMeasure(TextFieldBoxes.java:230)
at android.view.View.measure(View.java:16482)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5055)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1435)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:720)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:592)
at android.view.View.measure(View.java:16482)
at android.widget.ScrollView.measureChildWithMargins(ScrollView.java:1815)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
at android.widget.ScrollView.onMeasure(ScrollView.java:460)
at android.view.View.measure(View.java:16482)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5055)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
at android.view.View.measure(View.java:16482)
at com.afollestad.materialdialogs.internal.MDRootLayout.onMeasure(MDRootLayout.java:295)
at android.view.View.measure(View.java:16482)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5055)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
at android.view.View.measure(View.java:16482)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5055)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1435)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:720)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:592)
at android.view.View.measure(View.java:16482)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5055)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2560)
at android.view.View.measure(View.java:16482)
at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2195)
at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1340)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1551)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1237)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5162)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:791)
at android.view.Choreographer.doCallbacks(Choreographer.java:591)
at android.view.Choreographer.doFrame(Choreographer.java:561)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:777)
at android.os.Handler.handleCallback(Handler.java:725)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:176)
at android.app.ActivityThread.main(ActivityThread.java:5317)
at java.lang.reflect.Method.invokeNative(Method.java)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
at dalvik.system.NativeStart.main(NativeStart.java)

Thank you,

Password Visibility Toggle

Hi, from what I understand, your TextFieldBoxes is replacing TextInputLayout. If that's the case, are you planning to add support for password visibility toggle? I know we can achieve the same thing using endIcon, I was just curious if you are planning to add a support so we can show and hide password easily.

Wrap_content height issue

Hello, thanks for your lib, looks really nice :)

But i found some problem
android:layout_height="wrap_content" make view's height matching to parent height.
Expected behavior: height corresponds to the height of the EditText's lines

Reducing height

Hi, while i'm at it.

Been looking at reducing the height of the box, it is quite large on smaller screens, but i have been unsuccessful.

Is there any way to reduce padding, height etc?

Compact?

Any thoughts on supporting the compact Text Fields? How difficult would it be? I think support for these is coming in the design library but it seems to be moving very slowly.

Thanks

Don't create new objects in onDraw method

It's a best practice not to create new object in the critical path (onDraw is called a lot of time).

protected void onDraw(Canvas canvas) {
Path clipPath = new Path();
Float cornerRadius = context.getResources().getDimension(R.dimen.text_field_boxes_corner_radius);
clipPath.addRoundRect(new RectF(canvas.getClipBounds()), cornerRadius, cornerRadius, Path.Direction.CW);
canvas.clipPath(clipPath);
super.onDraw(canvas);
}

clipPath, cornerRadius, RectF could be initialized in onCreate method, and getClipBounds requested only when the view size changes.

Helper is misplaced when embedded in a ScrollView

The following layout has the following render:

<LinearLayout
    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="wrap_content">

    <studio.carbonylgroup.textfieldboxes.TextFieldBoxes
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:helperText="helper"
        app:labelText="Label">

        <studio.carbonylgroup.textfieldboxes.ExtendedEditText
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"/>
    </studio.carbonylgroup.textfieldboxes.TextFieldBoxes>

</LinearLayout>

screen shot 2018-02-26 at 23 46 13
which is expected, however the following layout (just replace LinearLayout with ScrollView) has the following render:

<ScrollView
    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="wrap_content">

    <studio.carbonylgroup.textfieldboxes.TextFieldBoxes
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:helperText="helper"
        app:labelText="Label">

        <studio.carbonylgroup.textfieldboxes.ExtendedEditText
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"/>
    </studio.carbonylgroup.textfieldboxes.TextFieldBoxes>

</ScrollView>

screen shot 2018-02-26 at 23 45 55

which is not what I expected.
Is this a bug?

Custom label margins

I want to have TextFieldBoxes with a height of 56dp but in this case inner label is cut (I guess because of big label margins). Can you give an opportunity to set custom label top and bottom margin?

Icon's color

  • How to set the icon's color?
  • Is there a way to set the icon's color as the primaryColor?

nextFocusDown between editTexts not working

Why?

<studio.carbonylgroup.textfieldboxes.TextFieldBoxes
            android:id="@+id/nick_input"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="16dp"
            app:iconSignifier="@drawable/ic_user_man_black"
            app:labelText="@string/login_nick_label"
            app:maxCharacters="16"
            app:primaryColor="@android:color/black">

            <studio.carbonylgroup.textfieldboxes.ExtendedEditText
                android:id="@+id/nick_edit_text"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:imeOptions="actionNext"
                android:inputType="text"
                android:maxLines="1"
                android:singleLine="true"
                android:nextFocusDown="@+id/password_edit_text" />

        </studio.carbonylgroup.textfieldboxes.TextFieldBoxes>

        <studio.carbonylgroup.textfieldboxes.TextFieldBoxes
            android:id="@+id/password_input"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="16dp"
            app:iconSignifier="@drawable/ic_login_password"
            app:labelText="@string/login_password_label"
            app:maxCharacters="32"
            app:primaryColor="@android:color/black">

            <studio.carbonylgroup.textfieldboxes.ExtendedEditText
                android:id="@+id/password_edit_text"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:imeOptions="actionGo"
                android:inputType="textPassword"
                android:maxLines="1" />

        </studio.carbonylgroup.textfieldboxes.TextFieldBoxes>

Move label up after calling setText()

After calling ExtendedEditText#setText(String s) TextFieldBoxes displays only its label, the text is not visible. I expect the following behavior: after setting a text the label moves to the top of TextFieldBoxes view and the text is shown in EditText.

Cursor in editext is missing

Cursor in editext is missing. Why?

<studio.carbonylgroup.textfieldboxes.TextFieldBoxes
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:panelBackgroundColor="@color/colorWhite"
                app:labelText="Email">
                <studio.carbonylgroup.textfieldboxes.ExtendedEditText
                    android:id="@+id/email"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content" />
</studio.carbonylgroup.textfieldboxes.TextFieldBoxes>

Change color of Label when not in focus

Great library, thanks. One issue - the "app:labelText" has the right color when the field is tapped and the text moves up into the upper left corner. When out of focus, though, it is white and none of the settings you have seem to make any difference. Would be great if it were possible to change that color as well.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.