I'm building a simple app with appcelerator.
I would like to set a background image on a view.
This is the code of tss
login.tss
".images":{
top: "15px",
left: "161px",
backgroundImage : "/images/logo_decipher.PNG",
width : "268px",
height : "213px"
}
this is a login.xml
<Alloy>
<View class="container">
<View class="images"></View>
<Label id="loginLable"
class="loginLable">Accedi</Label>
<TextField class="textLogin"></TextField>
<Button></Button>
</View>
</Alloy>
this is the folder where is my image:
If I try to start my application the image are not show
All images in Titanium need to be in the app/assets folder.
Within the app/assets folder you create an images folder, and in there you can add your images. Your path you already set will work in that case.
Be aware all images are case sensitive. In case your file is actually .PNG then leave it like that.
Related
I have been following the react-navigation getting started guide. I’ve not modified anything beyond adding...
options={{
...TransitionPresets.ModalPresentationIOS,
cardOverlayEnabled: true,
gestureEnabled: true,
headerShown: false
}}
...to the modal to make it look like iOS 13.
It works and animates great, but I’d like the back-background to be black. In the screenshot below, I’m talking about the darkest grey color that the time and battery icons are on.
I tried setting the background of the Theme to black, but that made all the cards black. Is there a way to only make that far-far background black?
I’m sure I’m not being clear, but thanks in advance for any guidance.
You should wrap your navigator into a View like this:
<View
style={{
backgroundColor: "black",
flex: 1,
}}
>
<Stack.Navigator>
{/* Your screens */}
</Stack.Navigator>
</View>
if i get your question right it's about the theme color, which you can find in the index.HTML file.
You should see a meta tag in the head which looks something like this:
<meta name="theme-color" content="#000000" />
Let me know if i got it right.
Long ago I searched on Internet for a SVG image plugin and found that one, which is almost broken, outdated and thus unusable. Is there any other plugin that I might miss that allows to show SVG images and works fine with recent Nativescript version?
For anyone still struggling with this, there is another route you could take. What ended up doing was converting my svg files into a font file (.tff). My svg files were simple, so I'm not sure if this will work for every case, but at least it works for using icons. It's really easy to convert svg files to a .ttf file. I used this online tool converter, then I added the file into my nativescript app/fonts folder. Now I can use a label like this to display the svg files:
<label
style="font-family: yourFontFileName;"
text="A" //This will show the icon mapping to the letter 'A'
></label>
It's also worth noting that since it's a font, you can change stroke color, and size.
Note: Android uses the file name as the font name, while IOS has its own font name. To find the font name you can just open your .ttf file, and it should open a window showing the letters (icons) and the font name as the title
There is an updated fork from teammaestro
<Page xmlns="http://schemas.nativescript.org/tns.xsd"
xmlns:svg="#teammaestro/nativescript-svg" loaded="pageLoaded">
<StackLayout>
<svg:SVGImage src="~/image/nativescript.svg" height="100" />
<svg:SVGImage src="https://media4.giphy.com/media/3uyIgVxP1qAjS/200.svg" height="200" />
<svg:SVGImage src="res://somesvg" height="200" />
</StackLayout>
</Page>
When Admin-on-rest is running on safari mobile (and presumably all small screens) wide views cannot be scrolled horizontally. This is particularly problematic because in List View often the "Edit" link is on the right of a row.
There is no way to pinch-zoom out to expose the missing parts of the page.
This can be reproduced on the demo site: https://marmelab.com/admin-on-rest-demo/#/
Looks like the culprit is a CSS style using flex-direction: column
Removing this style reinstates horizontal scrolling.
Is this a bug (possibly a cross-browser issue?) or is this limitation necessary for a reason that I'm not aware of?
Possible solution: Remove overflow-x: hidden on the table container which allows a wide table of results to be scrolled horizontally but keeps the overall page width the same size as the page so buttons/filters/etc are aligned correctly.
Don't use the datagrid on small screens. See the documentation about this: https://marmelab.com/admin-on-rest/Theming.html#responsive-utility
I'm using this way to horizontally scroll in small size devices:
export const ReservationList = (props) => (
<div style={{
display: "flex",
flex: "1 1 auto",
overflowY: "hidden",
overflowX: "scroll"
}}>
<List {...props} title="Reservation List">
<Datagrid>
...
</Datagrid>
</List>
</div>
);
I have an image of size 1024x1024 and I want to have it a background as an ImageView object. I've set the ImageView height and width to be the size of the device and loaded the image - what happens is that the image shows the entire image squeezed to the given dimensions.
What I would like to see is not the entire image - I want it to scale to show it centered, and the parts of the image that don't fit the screen to not show. What my end result should be just setting the height and the width whatever is disposable will be overflowed and hidden.
How can I set an image not to stretch?
What your looking for is a clipped image. This affect is best achieved using a combination of View with clipping turned on and an ImageView.
As an example, we'll use a large image and the code below.
<Alloy>
<Window class="container" backgroundColor="#000">
<View clipMode="Titanium.UI.iOS.CLIP_MODE_ENABLED" width="200">
<ImageView image="/images/Moonset_over_ESO's_Very_Large_Telescope.jpg" height="2336" width="3504"/>
</View>
</Window>
</Alloy>
Note that we have enabled clipping on the parent View, and are using it to define the actual width we want everything rendered on the Screen. The ImageView is then used with the actual width / height of the image to be rendered. Because we are not setting a top,left,right,bottom properties, the ImageView will render itself centered in the parent view, with its overflow hidden.
This provides the desired effect as shown in the image below.
I think you mean the image property of the ImageView and not the backgroundImage. If you use a normal view and set the backgroundImage it will be stretched. From the docs:
Specifying either a width or height property for this view will scale
its image(s) with the aspect ratio maintained, up to a maximum size
that does not exceed its parent view.
If you want to center the image you could just place it in a View and set the width/height to the max value (or calculate the aspect ratio and set both values corretly) and it will be centered in the surrounding View
XML
<Alloy>
<Window >
<ImageView id="img"/>
</Window>
</Alloy>
JS
$.img.image = "/images/1.jpg";
$.img.width = 200;
$.index.open();
Image original size: 1080x720. Display inside the app: 200px width not stretched and in the middle of the window (Android, Ti 5.1.2, TiShadow on device)
I currently have a right-aligned image in the main body of a WordPress post, which I have placed using the WYSIWYG editor. However, I would like to prevent this image from displaying on devices with a max-width of 320px.
I am using a responsive theme but do not wish to change the way that other images on the website behave. For this reason, is it possible to target that image specifically? If so, how would I do this?
Bonus: I originally wanted to change the alignment and margins of the image at mobile width but have been unable to figure out how to do this without changing the way that it behaves at bigger screensizes.
Have been unable to find a solution thus far.
Thanks!
you could use media queries on the editor go to the html editor an add an id to that particular image for example <img id="target" src="some/image.jpg" />
then you could paste this on your style.css file
#media only screen and (min-device-width : 320px) {
#target{ display: none; }
}