I have a problem on iOS with KeyboardAvoidingView that put the scrollview scrollbar on left or in the middle of the screen. The code is like following
<KeyboardAvoidingView
behavior={Platform.OS === 'ios' ? 'padding' : undefined}
style={{ flex: 1 }}
>
<ScrollView
style={{flex: 1}}
/>
</KeyboardAvoidingView>
I notive that embedding this code inside a SafeAreaView fix the problem (scrollbar on right) but visually I can't use it.
Does anyone encountered that strange behaviour ?
Related
I am forced to use multiline={false} and set the height of TextInput in order to show it like it is a text area. Reason is that multiline={true} doesn't work very well with KeyboardAvoidingView (https://github.com/facebook/react-native/issues/16826).
So here is a simple code:
<TextInput placeholder="Input text here..." style={{height: 200}} multiline={false} />
and the output is: Screenshot
I just want to make it the text align at the top. Works properly with Android though
Set style property textAlignVertical to top on the TextInput
<TextInput ... multiline={true} textAlignVertical: 'top' />
I have one window it's layout is vertical,i have added two child views for that window ,those views height will dynamically change.After adding the views to window,First view is not fit to it's contents some gap is coming.Please help me how to solve this.
below is my code
<Alloy>
<NavigationWindow id="profBidPostNav" platform="ios">
<Window id="profBidPostWin" layout="vertical">
<View id="MainView" height="Ti.UI.SIZE"></View>
<View id="customerServiceMainView" height="Ti.UI.SIZE" top="0%"></View>
</Window>
</NavigationWindow>
Can you add a screenshot to see the problem ?
I see two errors on your code, hieght instead of height and top="0%". If your Window have vertical layout, no need to add top property.
<Window id="profBidPostWin" layout="vertical">
<View id="MainView" height="Ti.UI.SIZE"></View>
<View id="customerServiceMainView" height="Ti.UI.SIZE"></View>
</Window>
I don't know if I'm missing something or if this is a bug, paper-fab buttons always "force a new line". So, I can't get several paper-fab buttons aligned horizontally. I have tried <span>ing them:
<span>
<paper-fab mini icon='arrow-forward' on-click='onClickForward'></paper-fab>
<paper-fab mini icon='arrow-backward' on-click='onClickBackward'></paper-fab>
</span>
and they are stacked vertically.
Just set display to inline-block
<style>
paper-fab {
display: inline-block;
}
</style>
I was trying to make the TextInput to be auto scaling, that is, the height of the TextInput increases as the text is wrapped to next line.
So I'm trying to calculate the width of the text, and compare it width the width of the TextInput. If it's greater than the width, the height of the TextInput will increase.
So my question is how to calculate the width of the text?
Are there any other ways to accomplish the auto scaling effect?
Thanks!
Currently there is no easy way to get the inner content width of a TextInput.
React Native is badly in need of an autosizing text input like the one you describe. I could use one also, so when I find time I may try to write one.
In the meantime, here's a workaround for accomplishing what you describe:
Create your TextInput with its initial (fixed) height.
Create a cloned <Text> element somewhere offscreen (e.g. use absolute position) with the same style as the TextInput. This is easy to do thanks to the declarative nature of React's style attribute. Set the width to the same width as your TextInput.
If your TextInput has responsive width, you may want to look at onLayout, or measure to get the width, otherwise there are ways to automatically render the clone with the same width (e.g. place it in the same container but offscreen).
Write an onChange handler for the TextInput which:
(a) Updates the clone's any time the TextInput text changes
(b) Measures the height of the clone (since <Text> elements autosize)
(c) Sets the new height of the Textinput
Although this is kind of a pain, you only have to write it once. It can easily be encapsulated into a component (e.g. ) which you can then re-use with impunity.
Though I'm not answering the question asked, I want to point out that the auto-scaling TextInput can be easily implemented in React Native 0.34.
class AutoScaleTextInput extends React.Component {
constructor() {
super();
this.state = {
inputHeight: 35
};
}
render() {
return (
<TextInput
multiline={true}
style={{
height: this.state.inputHeight
}}
onContentSizeChange={ this._onTextContentSizeChange }/>
);
}
_onTextContentSizeChange = (event) => {
this.setState({
inputHeight: Math.min(event.nativeEvent.contentSize.height, 100)
});
}
}
See: TextInput#onContentSizeChange
Expo Snack example https://snack.expo.io/HkqE2AhAe
I have stackPanel created in design (xmal) which has Auto height and width. Adding list of image controls dynamically in Code on Load to stackPanel. Now it works fine. But when i try to resize the window, though the stack panel gets resized due to auto, but not the image contrl.
How to bind the actualheight of stackpanel dynamically to image control height, (so when ever stakpanl height gets changed ,image control also should get changed !!).
thanks
Use a ViewBox
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
<Viewbox MaxWidth="500" MaxHeight="500" Name="vb1">
<Image Source="tulip_farm.jpg"/>
</Viewbox>
</StackPanel>
How to: Apply Stretch Properties to the Contents of a Viewbox
Or you could use binding as below:
<StackPanel x:Name="MyStackPanel">
<Image Source="C:\Users\Public\Pictures\Sample Pictures\Chrysanthemum.jpg" Stretch="Uniform" Height="{Binding ElementName=MyStackPanel, Path=ActualHeight}"></Image>
</StackPanel>