mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-17 21:01:34 +08:00
Merge pull request #1847 from NativeScript/button-formatted-text-android-
TransformationMethod set to null in order to apply formattedText
This commit is contained in:
@ -12,6 +12,16 @@
|
|||||||
</FormattedString>
|
</FormattedString>
|
||||||
</Label.formattedText>
|
</Label.formattedText>
|
||||||
</Label>
|
</Label>
|
||||||
|
<Label>
|
||||||
|
<Label.formattedText>
|
||||||
|
<FormattedString>
|
||||||
|
<FormattedString.spans>
|
||||||
|
<Span text="label" fontAttributes="Bold" foregroundColor="#0000ff" />
|
||||||
|
<Span text="Label" fontAttributes="Italic" foregroundColor="#00ff00" />
|
||||||
|
</FormattedString.spans>
|
||||||
|
</FormattedString>
|
||||||
|
</Label.formattedText>
|
||||||
|
</Label>
|
||||||
|
|
||||||
<Button text="buttonButton" style="text-transform: uppercase; text-decoration: underline line-through;" />
|
<Button text="buttonButton" style="text-transform: uppercase; text-decoration: underline line-through;" />
|
||||||
<Button style="text-transform: uppercase; text-decoration: underline line-through;">
|
<Button style="text-transform: uppercase; text-decoration: underline line-through;">
|
||||||
@ -24,6 +34,16 @@
|
|||||||
</FormattedString>
|
</FormattedString>
|
||||||
</Button.formattedText>
|
</Button.formattedText>
|
||||||
</Button>
|
</Button>
|
||||||
|
<Button>
|
||||||
|
<Button.formattedText>
|
||||||
|
<FormattedString>
|
||||||
|
<FormattedString.spans>
|
||||||
|
<Span text="button" fontAttributes="Bold" foregroundColor="#0000ff" />
|
||||||
|
<Span text="Button" fontAttributes="Italic" foregroundColor="#00ff00" />
|
||||||
|
</FormattedString.spans>
|
||||||
|
</FormattedString>
|
||||||
|
</Button.formattedText>
|
||||||
|
</Button>
|
||||||
|
|
||||||
<TextField text="textField" style="text-transform: uppercase; text-decoration: underline line-through;" />
|
<TextField text="textField" style="text-transform: uppercase; text-decoration: underline line-through;" />
|
||||||
<TextField style="text-transform: uppercase; text-decoration: underline line-through;">
|
<TextField style="text-transform: uppercase; text-decoration: underline line-through;">
|
||||||
@ -36,6 +56,16 @@
|
|||||||
</FormattedString>
|
</FormattedString>
|
||||||
</TextField.formattedText>
|
</TextField.formattedText>
|
||||||
</TextField>
|
</TextField>
|
||||||
|
<TextField>
|
||||||
|
<TextField.formattedText>
|
||||||
|
<FormattedString>
|
||||||
|
<FormattedString.spans>
|
||||||
|
<Span text="text" fontAttributes="Bold" foregroundColor="#0000ff" />
|
||||||
|
<Span text="Field" fontAttributes="Italic" foregroundColor="#00ff00" />
|
||||||
|
</FormattedString.spans>
|
||||||
|
</FormattedString>
|
||||||
|
</TextField.formattedText>
|
||||||
|
</TextField>
|
||||||
|
|
||||||
<TextView text="textView" style="text-transform: uppercase; text-decoration: underline line-through;" />
|
<TextView text="textView" style="text-transform: uppercase; text-decoration: underline line-through;" />
|
||||||
<TextView style="text-transform: uppercase; text-decoration: underline line-through;">
|
<TextView style="text-transform: uppercase; text-decoration: underline line-through;">
|
||||||
@ -48,6 +78,16 @@
|
|||||||
</FormattedString>
|
</FormattedString>
|
||||||
</TextView.formattedText>
|
</TextView.formattedText>
|
||||||
</TextView>
|
</TextView>
|
||||||
|
<TextView>
|
||||||
|
<TextView.formattedText>
|
||||||
|
<FormattedString>
|
||||||
|
<FormattedString.spans>
|
||||||
|
<Span text="text" fontAttributes="Bold" foregroundColor="#0000ff" />
|
||||||
|
<Span text="View" fontAttributes="Italic" foregroundColor="#00ff00" />
|
||||||
|
</FormattedString.spans>
|
||||||
|
</FormattedString>
|
||||||
|
</TextView.formattedText>
|
||||||
|
</TextView>
|
||||||
|
|
||||||
</StackLayout>
|
</StackLayout>
|
||||||
</Page>
|
</Page>
|
@ -44,9 +44,21 @@ export class Button extends common.Button {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _transformationMethod;
|
||||||
public _setFormattedTextPropertyToNative(value) {
|
public _setFormattedTextPropertyToNative(value) {
|
||||||
var newText = value ? value._formattedText : null;
|
var newText = value ? value._formattedText : null;
|
||||||
if (this.android) {
|
if (this.android) {
|
||||||
|
if (newText) {
|
||||||
|
if (!this._transformationMethod) {
|
||||||
|
this._transformationMethod = this.android.getTransformationMethod();
|
||||||
|
}
|
||||||
|
this.android.setTransformationMethod(null);
|
||||||
|
} else {
|
||||||
|
if (this._transformationMethod && !this.android.getTransformationMethod()) {
|
||||||
|
this.android.setTransformationMethod(this._transformationMethod);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.android.setText(newText);
|
this.android.setText(newText);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user