Android EditText view pływająca podpowiedź w Material Design
Czy API 21 zapewnia metodę użycia następującej funkcji:
Http://www.google.com/design/spec/components/text-fields.html#text-fields-floating-labels
Próbuję wypuścić wskazówki EditText.
Dzięki!
9 answers
Floating hint EditText:
Dodaj poniżej zależność w gradle:
compile 'com.android.support:design:22.2.0'
W układzie:
<android.support.design.widget.TextInputLayout
android:id="@+id/text_input_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/editText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="UserName"/>
</android.support.design.widget.TextInputLayout>
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2015-07-01 07:35:12
Tak, od 29 maja 2015 ta funkcjonalność jest teraz dostępna w Android Design Support Library
Ta biblioteka zawiera wsparcie dla
- pływające etykiety
- Pływający przycisk akcji Snackbar]}
- Szuflada nawigacyjna
- i więcej
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2015-06-02 08:54:28
Biblioteka wsparcia dla Androida może być zaimportowana w gradle w zależności:
compile 'com.android.support:design:22.2.0'
Powinno być zawarte w GradlePlease! I jako przykład do użycia:
<android.support.design.widget.TextInputLayout
android:id="@+id/to_text_input_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<AutoCompleteTextView
android:id="@+id/autoCompleteTextViewTo"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="To"
android:layout_marginTop="45dp"
/>
</android.support.design.widget.TextInputLayout>
Btw, edytor może nie rozumieć, że AutoCompleteTextView jest dozwolone w TextInputLayout.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2015-06-10 13:22:46
Android nie dostarczył natywnej metody. Ani AppCompat.
Wypróbuj tę bibliotekę: https://github.com/rengwuxian/MaterialEditText
To może być to, czego chcesz.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2014-11-08 14:37:58
Zaimportuj biblioteki wsparcia w kompilacji twojego projektu.plik gradle, dodaj następujące linie w zależności projektu:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:design:22.2.0'
compile 'com.android.support:appcompat-v7:22.2.0'
}
Użyj następującego TextInputLayout w układzie UI:
<android.support.design.widget.TextInputLayout
android:id="@+id/usernameWrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/username"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textEmailAddress"
android:hint="Username"/>
</android.support.design.widget.TextInputLayout>
Następnie wywołaj setHint na TextInputLayout zaraz po wywołaniu setContentView, ponieważ aby animować pływającą Etykietę, wystarczy ustawić podpowiedź, używając metody setHint.
final TextInputLayout usernameWrapper = (TextInputLayout) findViewById(R.id.usernameWrapper);
usernameWrapper.setHint("Username");
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2015-09-01 06:58:53
@ Andruboy ' s suggestion of https://gist.github.com/chrisbanes/11247418 to chyba najlepsza opcja.
Https://github.com/thebnich/FloatingHintEditText trochę działa z appcompat-v7 v21.0.0, ale ponieważ v21.0. 0 nie obsługuje kolorów akcentów z podklasami EditText
, podkreślenie FloatingHintEditText
będzie domyślnym pełnym czarnym lub białym. Również wyściółka nie jest zoptymalizowana pod kątem stylu materiału EditText
, więc może być konieczne dostosowanie go.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2014-10-22 20:03:56
Nie ma. spodziewałbym się tego w przyszłym wydaniu api, ale na razie utknęliśmy z EditText. Inną opcją jest ta biblioteka:
https://github.com/marvinlabs/android-floatinglabel-widgets
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2014-11-06 18:26:51
Try this way
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:design:23.0.1'
}
Aby uzyskać więcej informacji kliknij tutaj
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2016-01-13 07:36:41
Aby ułatwić korzystanie z InputTextLayout, stworzyłem tę bibliotekę, która tnie Twój kod XML do mniej niż połowy, a także zapewnia możliwość ustawienia komunikatu o błędzie, a także komunikatu podpowiedzi i łatwego sposobu dokonywania walidacji. https://github.com/TeleClinic/SmartEditText
Po prostu dodaj
compile 'com.github.TeleClinic:SmartEditText:0.1.0'
Wtedy możesz zrobić coś takiego:
<com.teleclinic.kabdo.smartmaterialedittext.CustomViews.SmartEditText
android:id="@+id/emailSmartEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:setLabel="Email"
app:setMandatoryErrorMsg="Mandatory field"
app:setRegexErrorMsg="Wrong email format"
app:setRegexType="EMAIL_VALIDATION" />
<com.teleclinic.kabdo.smartmaterialedittext.CustomViews.SmartEditText
android:id="@+id/passwordSmartEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:setLabel="Password"
app:setMandatoryErrorMsg="Mandatory field"
app:setPasswordField="true"
app:setRegexErrorMsg="Weak password"
app:setRegexType="MEDIUM_PASSWORD_VALIDATION" />
<com.teleclinic.kabdo.smartmaterialedittext.CustomViews.SmartEditText
android:id="@+id/ageSmartEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:setLabel="Age"
app:setMandatory="false"
app:setRegexErrorMsg="Is that really your age :D?"
app:setRegexString=".*\\d.*" />
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2017-12-22 09:17:37