Comments (4)
@isaacfi - I think you'd have to look at styling options for the android TextInputLayout
documentation to know what all you can control on the floating label. You're likely needing to use the hintTextAppearance
attribute and XML styles as documented in the README.
Questions like this really should go on Stack Overflow - github issues are more for bug reports. 😄 Odds are, there's someone that's already ran into this and knows exactly how to style that hint text.
from nativescript-textinputlayout.
This is an issue, the problem is that hintTextApperance style cannot add margin because it is a TextAppearance Style. I implemented the lineHeight property for android in your plugin after reading this stackoverflow answer: TextInputLayout :How to give padding or margin to hint?
I share you the android code:
export const lineHeightProperty = new Property<TextInputLayout, number>({
name: "lineHeight",
affectsLayout: true,
valueConverter: v => parseFloat(v)
});
private setupTextView() {
if (!this.isLoaded) {
return;
}
const textField = this._textField;
const nativeView = this.nativeView;
const layoutParams = new (<any>android).widget.LinearLayout.LayoutParams(
(<any>android).widget.LinearLayout.LayoutParams.MATCH_PARENT,
(<any>android).widget.LinearLayout.LayoutParams.WRAP_CONTENT);
const current = nativeView.getEditText();
const nativeTextField = textField.nativeView;
if (current !== nativeTextField) {
if (current) {
nativeView.removeView(current);
}
if (this.lineHeight) {
var paddingView = new (<any>android).view.View(this._context);
const layoutParamsPaddingView = new (<any>android).widget.LinearLayout.LayoutParams(
(<any>android).widget.LinearLayout.LayoutParams.MATCH_PARENT,
this.lineHeight);
nativeView.addView(paddingView, 0, layoutParamsPaddingView);
}
nativeView.addView(nativeTextField, 0, layoutParams);
}
// sometimes hint text isn't immediately triggered to move when navigating back to a prior view.
// this triggers it via brute force :(
const txtValue = textField.nativeView.getText();
nativeTextField.setText('');
nativeTextField.setText(txtValue);
}
[lineHeightProperty.setNative](value: number) {
if (!isNaN(value)) {
this.lineHeight = value;
}
}
exports.lineHeightProperty.register(TextInputLayout);
textInputLayout.android.ts.zip
Regards
from nativescript-textinputlayout.
While this may be an issue in the broader sense of the word, the aim of this component is simply parity with the native TextInputLayout
component. I don't feel that doing this adding of a spacer block (the padding view) is appropriate in this level, so I'm not ready to call this an issue within the realm of this repo at this time.
What about other answers (i.e. the accepted answer) in that same thread that says that the paddingTop
style on the EditText
element works to accomplish this same thing? The solution you went with is near the bottom, has almost no votes, and isn't the accepted answer for the issue at hand - not sure why that one was picked over the established/accepted solution.. does the accepted one no longer work or something?
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="@dimen/floating_hint_margin"
android:background="@drawable/bg_edit_text" />
</android.support.design.widget.TextInputLayout>
from nativescript-textinputlayout.
I've tested the other ones, but they depends on configuration and the padding top size would be static. Test the solution that I shared you.
Cheers
from nativescript-textinputlayout.
Related Issues (20)
- How to use this in Nativescript angular HOT 4
- How to use in Nativescript Angular iOS? HOT 5
- changing hint color HOT 5
- Error on iOS Build regarding Swift version HOT 1
- secure="true" ignored on TextField HOT 9
- Unable to Style the TextField HOT 9
- keyboardType not working on ios HOT 3
- bottom line styling on android? HOT 2
- Support for Nativescript 4.x.x HOT 1
- iOS Angular binding HOT 4
- Unable to build project for iOS with this plugin and Xcode 9 HOT 3
- Better example on how to style on Android HOT 1
- Maintainable fix for Unable to determine Swift version, after compilation Pod fix got wiped out HOT 1
- Unable to build - require a higher minimum deployment HOT 1
- Custom font not working on Android HOT 1
- Is unified syntax possible? HOT 4
- Element with error does not auto-scroll above the soft keyboard
- Problems to build in IOS HOT 1
- Upgrade to tns 6.0 crashes on TextInputLayout HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nativescript-textinputlayout.