I am trying to make it so I have the MENU label on the far left of the ActionBar and the logo in the center, for iOS.
<template>
<ActionBar>
<GridLayout backgroundColor="green" columns="*, *" rows="*, *">
<Label v-if="isIos" row="0" col="0" text="MENU" #tap="openDrawer()" class="c-actionbar_label_ios"/>
<Image v-if="isIos" row="0" col="1" #tap="goToHome()" src="~/assets/images/sklar-logo.png" class="c-actionbar_logo"/>
</GridLayout>
</ActionBar>
</template>
The problem is that GridLayout stays right in the center and doesn't stretch the full width. I was thinking *,* meant two columns 50% width each, but that must not be the case. I put a green background on it so you can see the current width.
Is there some way to do accomplish this layout with GridLayout or any other layout? I've messed with FlexBoxLayout also, but can't get that to do what I want because you cant use % widths.
Related
I created a solution (see code here) from a blank Xamarin Forms template, running the latest stable version of Xamarin Forms. I added the experimental Shapes and SwipeView as required into my native projects, and I have a list of rows just saying "Hello" inside a Collection View.
I attempted to add a semicircle shape to the right swipe item's Grid, so it looks like the row has a rounded edge instead of rectangular shape.
But as you can see in the image below, the Shape just disappears after swiping to the right the second time. And occasionally the shape won't even appear in the row's swipe item.
Please note that the label always displays though, its just the shape going away. Also tested in Android & noticed the same behaviour. Do you know what the issue might be and if there's a work around?
Edit: Posted this and got a response to create an issue. Still looking for a workaround though
You can use Frame with CornerRadius to achieve the result:
<StackLayout Orientation="Horizontal" Padding="0" Margin="0" Spacing="0">
<Label
Text="Left"
HorizontalOptions="CenterAndExpand"
VerticalOptions="CenterAndExpand" />
<!--<Path HorizontalOptions="EndAndExpand" Fill="White" Stroke="White" Aspect="Fill" Data="m0.19956,-0.20844l14.43749,0l0,0c7.97347,0 14.43748,6.51981 14.43748,14.56254c0,8.04265 -6.464,14.5625 -14.43748,14.5625l-14.43749,0l0,-29.12504z" >
<Path.RenderTransform>
<RotateTransform CenterX="14.637"
CenterY="14.3541"
Angle="180" />
</Path.RenderTransform>
</Path>-->
<Frame BackgroundColor="Yellow" CornerRadius="30" IsClippedToBounds="True" HeightRequest="30" WidthRequest="30" HorizontalOptions="End" Margin="0,0,-51,0">
</Frame>
</StackLayout>
In android, I can't seem to make my TabViewItem icon sizes larger. I tried adding an explicit height and width in the XML but that doesn't change anything. Right now, it looks like this: https://imgur.com/a/PudvqwF which is too small for me. I also tried giving it a class and changing via CSS but still no luck . My code is as follows:
<TabViewItem :title='`FAVORITES ${this.favorites && this.favorites.length ? this.favorites.length : ""}`' width="60" height="60" iconSource="~/assets/images/heart-Icon.png">
<Frame
id="favorites-list-frame"
row="0"
>
<CustomComponent/>
</Frame>
</TabViewItem>
Any way to make these larger?
I have an NS 6 app and testing on an iPhone 6+ with iOS 13.
In this app I have a ListView and in the ListView I have a nativescript-carousel.
In the carousel I have an image component that loads an external image. The issue is that when I load the page, the image is loaded, but the parent does not expand vertically to accommodate the full height of the image. I can only see a small portion of it.
I tried refreshing the ListView and calling page.requestLayout(), but that did not help. If I set the image height, everything works, but the issue is that some of the carousel items may not have an image, so I cannot commit to a set height.
Here is my code (truncated for brevity):
<ListView id="lst" items="{{ asks }}">
<ListView.itemTemplate>
<StackLayout class="ask-item">
…
<GridLayout rows="*" columns="*" marginTop="10">
<ns:Carousel items="{{ recs }}" color="white" pageChanged="myChangeEvent" android:indicatorAnimation="slide" indicatorColor="#999999" indicatorColorUnselected="#dddddd" indicatorOffset="0,15" showIndicator="true">
<ns:Carousel.itemTemplate>
<ns:CarouselItem backgroundColor="#f9f9f9" verticalAlignment="middle">
<StackLayout class="rec-item">
…
<Image src="{{ image }}" stretch="aspectFit" horizontalAlignment="center" />
…
</StackLayout>
</ns:CarouselItem>
</ns:Carousel.itemTemplate>
</ns:Carousel>
</GridLayout>
</StackLayout>
</ListView.itemTemplate>
</ListView>
What is the best way to handle this issue?
Thank you.
By nature iOS ListView height can not be changed once rendered, you will have to update the specific list item.
Try downloading the image upfront or listen to isLoading property change, once then capture the height of the raw image and bind the height to the layout. The images height could be in raw pixel, you might want to convert that into density independent pixel for better display on high resolution devices.
I have a scrollview with an image at the top, then a searchbar and a list. I'm trying to make it so that the searchbar doesn't leave the top of the page when scrolling up so that the list keeps scrolling underneath it.
Format:
<ScrollView>
<Image src="testimage.png"></Image>
<Searchbar></Searchbar>
<ListView items></ListView>
</ScrollView>
Is there a way to do this in NativeScript?
Use GridLayout, ListView itself has built-in scrollbar.
<GridLayout rows="auto,auto,*">
<!-- you might want to set a height for image, depends on your image source -->
<Image row="0" src="testimage.png"></Image>
<Searchbar row="1"></Searchbar>
<ListView row="2" ...></ListView>
</GridLayout>
I want to align one image to the top and one image to the bottom of a RelativeLayout in Xamarin.Forms.
How can I do this?
<RelativeLayout>
<Image
Aspect="Fill"
Source = "header_login.png"></Image>
<Image
Aspect="Fill"
Source = "login_footer_2.png"
RelativeLayout.XConstraint=
"{ConstraintExpression Type=RelativeToParent,
Property=Width,
Factor=0}"
RelativeLayout.YConstraint=
"{ConstraintExpression Type=RelativeToParent,
Property=Height,
Factor=1}" ></Image>
</RelativeLayout>
I found something may be useful for you. Even if it is not done by using RelativeLayout, you can still have what you want by using StackLayout.
The idea is :
<StackLayout>
<StackLayout VerticalOptions="Start">
<Image/> <!--top image-->
</StackLayout>
<StackLayout VerticalOptions="CenterAndExpand">
<!-- middle controls -->
</StackLayout>
<StackLayout Orientation="Horizontal" VerticalOptions="End">
<Image/> <!--bottom image-->
</StackLayout>
</StackLayout>
By Expanding the Middle StackLayout take al the remained spaces pushing the other one on top and on bottom respectively. It was very useful to me to have a fixed bottom.
https://stackoverflow.com/a/30143144/3324840
The relative layout provides a very easy way to do this.
You should use the constraint type "relative to parent" and use factors to position the element.
Relative layout can include the control size when positioning with factors. What that means is that if you put a factor of 0, the top of the image will be at the top of the container.
If you put a factor of 1, the bottom of the image will be at the bottom of the container.
Likewise, a factor of 0.5 will center the center of your image on the center of the container
So, relative layout by default takes care of your control dimensions when calculating factored positions.
You can find a lot more info and samples on the relative container in the official documentation. There are also code samples included in the sample projects to help you out.