What properties it is necessary to set view1, so that it fills the rest of the window? - appcelerator

What properties it is necessary to set view1, so that it fills the rest of the window?
<Alloy>
<Window>
<View id="view1">
</View>
<View id="view2" height="50">
</View>
</Window>
</Alloy>

<Alloy>
<Window>
<View id="view1" top="0" bottom="50" width="100%">
</View>
<View id="view2" height="50" bottom="0" width="100%">
</View>
</Window>
</Alloy>
Also it is good to put the dimensions in the style (TSS) file instead of putting them in the view XML file. If this resolves your query then mark it as an answer for the reference for the rest of the community.

There are multiple ways to fill dimensions. It depends on what kind of layout type you have used like - vertical, horizontal or composite (default).
Vertical
Aligns children below each other.
You can control width, left, right, top & bottom properties. (bottom property doesn't work for last child)
Last child can occupy rest of the vertical height of parent.
Horizontal:
Aligns children from left-to-right in horizontal plane.
Can control left, right, top & bottom properties (right property doesn't work for last child).
Last child can occupy remaining width of view
Composite or default
Most flexible if you have not oriented UI.
Can keep views anywhere using top,left,right,bottom.
Assigning left & right only will define the width. Adding width with left & right will obey width keeping left & right restrictions.
-- e.g. if left & right = 20 & width=Ti.UI.SIZE, then view will start from left & will have width as Ti.UI.SIZE & will not go beyond right=20
Same rule as above applies for height as well.

Related

How to display bars from left to right with a fixed bar gap?

I want to display bars from left to right with a fixed bar gap, rather than display them evenly.
I have tried to add barCategoryGap or barGap prop with fixed number, but no influence for the chart like this:
And my code is:
<BarChart data={data} barSize={10} barCategoryGap={1}>
<YAxis
...some props
/>
<Tooltip />
<Bar dataKey="responseTime">
{data.map((item, index) => (
<Cell fill={item.isPass ? '#3c763d' : '#a94442'} key={index} />
))}
</Bar>
</BarChart>
In your graph, you don't have any XAxis specified to group your bars into categories. Because of this, the props barGap and barCategoryGap won't work, since there is no category to make changes on.
To solve your problem, you should add the missing XAxis which datakey would be a prop in your data object array, that shares the same object where your Bars values come from so that they can be regrouped. Afterwards you can "play" around with the gap between the different bars, just like a demo found on Recharts for Bars.

Dialog % height of the screen

I'd like to make the dialog(https://vuetifyjs.com/en/components/dialogs/) fill x% width and x% height of the screen. setting the width=80% does work as expected, the height does nothing though. any idea how to do this?
You need to set the height for the component inside the dialog. For eg, if you are using v-card, inside v-dialog then set the height of v-card. v-dialog will then scale accordingly.
<v-dialog
v-model="dialog"
width="50%"
>
<v-card height="50vh">
//Card contents
</v-card>
</v-dialog>

Xamarin Forms: AbsoluteLayout

I need to use an AbsoluteLayout for other controls on the page not listed here. How do I layout a common senerio where I have a SearchBar at the top, then a ListView which fills the rest of the screen.
I tried this, but the ListView goes incorrectly under the SearchBar
<AbsoluteLayout VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand">
<SearchBar></SearchBar>
<ListView
AbsoluteLayout.LayoutFlags="All"
AbsoluteLayout.LayoutBounds="0,0,1,1">
</ListView>
</AbsoluteLayout>
Part of the problem is AbsoluteLayoutFlags you have set on the listview.
when you set it to all, you are telling the layout to start at 0,0 and go all the way to 1,1. Which is why the listview is appearing on the searchbar.
<AbsoluteLayout VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand">
<SearchBar AbsoluteLayout.LayoutBounds="0,0,1,40"
AbsoluteLayout.LayoutFlags="WidthProportional,PositionProportional"/>
<ListView
AbsoluteLayout.LayoutFlags="XProportional,SizeProportional"
AbsoluteLayout.LayoutBounds="0,40,1,1">
<ListView.ItemsSource>
<x:Array Type="{x:Type x:String}">
<x:String>mono</x:String>
<x:String>monodroid</x:String>
<x:String>monotouch</x:String>
<x:String>monorail</x:String>
<x:String>monodevelop</x:String>
<x:String>monotone</x:String>
<x:String>monopoly</x:String>
<x:String>monomodal</x:String>
<x:String>mononucleosis</x:String>
</x:Array>
</ListView.ItemsSource>
</ListView>
</AbsoluteLayout>
Xamarin Documentation
I am sure you were referencing the documentation. I linked it here and quoting part of it. Hopefully it helps.
Proportional values define a relationship between a layout and a view.
This relationship defines a child view's position or scale value as a
proportion of the corresponding value of the parent layout. These
values are expressed as doubles with values between 0 and 1.
Proportional values are used to position and size views within the
layout. So, when a view's width is set as a proportion, the resultant
width value is the proportion multiplied by the AbsoluteLayout's
width. For example, with an AbsoluteLayout of width 500 and a view set
to have a proportional width of .5, the rendered width of the view
will be 250 (500 x .5).

UWP - positioning ruler using matrix transform inside zoomable ScrollViewer

I have InkCanvas inside a zoomable ScrollViewer:
<ScrollViewer x:Name="ScrollViewer" ZoomMode="Enabled">
<Border Height="5000" Width="5000" BorderBrush="Black" BorderThickness="1">
<InkCanvas x:Name="inkCanvas" />
</Border>
</ScrollViewer>
I want to position ruler to the top left corner.
Ruler is positioned on the InkCanvas and state of ScrollViewer is defined by by HorizontalOffset, VerticalOffset and ZoomFactor
I've found this code (sample)
void OnBringIntoView(e)
{
// Set Ruler Origin to Scrollviewer Viewport origin.
// The purpose of this behavior is to allow the user to "grab" the
// ruler and bring it into view no matter where the scrollviewer viewport
// happens to be. Note that this is accomplished by a simple translation
// that adjusts to the zoom factor. The additional ZoomFactor term is to
// make ensure the scale of the InkPresenterRuler is invariant to Zoom.
Matrix3x2 viewportTransform =
Matrix3x2.CreateScale(ScrollViewer.ZoomFactor) *
Matrix3x2.CreateTranslation(
ScrollViewer.HorizontalOffset,
ScrollViewer.VerticalOffset) *
Matrix3x2.CreateScale(1.0f / ScrollViewer.ZoomFactor);
ruler.Transform = viewportTransform;
}
in short:
viewport = Scale(zoom) * Translate(offset) * Scale(1/zoom)
This works, but I'm a bit lost.
What does the first scale do and what does the second? Why can't I use juct TranslateTransform?
Why can't I use juct TranslateTransform?
Because the InkPresenterRuler.Transform property is designed to be Matrix3x2.
What does the first scale do and what does the second?
Scale(zoom)*Scale(1/zoom) aiming at letting the ruler be invariant to Zoom. No matter what your current zoom level is, the ruler will return to it's original size.
Translate(offset) changes the translation values(offsetX and offsetY) of the transform Matrix.
For details of the transformation theory you can refer to:
Remarks of Matrix Transform
Affine transformations section of Transformation matrix Wiki.

Wrapping text around an image with React-Native

I try to create a View with an Image and a Text component that wraps around the Image component.
My styling:
textContainer: {
flexDirection: 'row',
},
text: {
flex: 10,
},
image: {
flex:1,
height: 180,
width: 150,
margin: 10,
borderColor: '#ccc',
borderWidth: 1,
}
My component:
<ScrollView style={styles.contentContainer} >
{this.props.content.title_1 ? <Text style={styles.title}>{this.props.content.title_1}</Text> : null}
<View style={styles.textContainer}>
{this.props.content.text_1 ? <Text style={styles.text}>{this.props.content.text_1}</Text> : null}
{this.props.content.image_1 ? <Image width={null} height={null} style={styles.image} source={this.props.content.image_1} /> : null}
</View>
</ScrollView>
This is what the result: (not wrapping at all haha)
In the image beneath here, I quickly hacked the little image into the text. But I can't get the text to be wrapped around..
I hope anyone can help me in the right direction!
This is really hard but there is one weird way to do this.. Try the following. It worked for me but place I am doing this is too deep in the other views.:
<Text>
<View style={{width:400, height:100, flex:1, flexDirection:'row'}}>
<Image source={require('')}/>
<Text>Your Content Here</Text>
</View>
</Text>
Good luck. Please put a comment letting us know if it worked.
On android you cannot place a View inside Text, but you can place an Image, here is an example:
<Text>
<Image source="" />
<Text> Insert your text here </Text>
</Text>
Although this is an old post, I'll add this because I have recently had this problem and found a totally different approach that works for me. I don't have the code to hand (I can get it if anyone wants it), but the principle was this:
Requirement: to have a picture in the top left corner of the screen that takes up about half the screen width, with text starting to the right of it and then continuing beneath it for the whole width of the screen.
In XML, create a RelativeLayout containing an ImageView (IV) on the left and a TextView (TVA), set to wrap content, on the right. Then create another TextView (TVB) to sit below the Relative Layout. TVA is for the text beside the image and TVB for the text beneath it.
Put your image in IV. Then measure the height of IV in pixels (dpi). Call this height IVh
Put some of your text in TVA. As long as there is enough text to wrap over several lines, it doesn't really matter how much. Then measure the height of TVA in pixels. Call this height TVh
Compare IVh with TVh. If IVh=TVh then you have just the right amount of text to sit alongside your image. If TVh = IVh x 2 then you have twice as much text as you should have. And so on.
Adjust the number of words accordingly and put the right number into TVA, replacing what was there, then put the rest of the text in TVB.
You will need to play with margins and padding to allow an adequate margin around the image. Also, in steps 3 and 4 after you have put your image into ImageView or your text into TextView, you will need a delay before measuring the heights, to allow the display to be created - otherwise the measurement will be done too soon, before there is anything on the screen, and will return a height of zero. I found 200 milliseconds quite adequate and it's too fast for the user to notice a delay.

Resources