I am making app for mobile ,7" tablet(600*1024) and 10" tablet(720*1280). I created the following folders for layout and drawable.
drawable-hdpi
drawable-land-hdpi
drawable-land-mdpi
drawable-large-mdpi
drawable-large-port-mdpi
drawable-ldpi
drwable-mdpi
layout
layout-sw600dp(7")
layout-sw720dp(10")
layout-land
layout-sw600dp-land(7")
layout-sw720dp-land(10")
It is working fine on mobile but not working in tablets.It is giving null pointer exception for relative layout on fist screen of the app.It is not picking relative layout from XML while using tablet.I am testing on emulator.Can anybody help me.
Thanks in advance
I was also facing same problem. RelativeLayout was id was null when I tested on tablet.
Problem was: By mistake I didn't added RelativeLayout in my layout xml corresponding to tablet, meaning large-layout.
Here in your case these (layout-sw600dp(7"), layout-sw720dp(10"), layout-sw600dp-land(7"), layout-sw720dp-land(10")) are folders related to large screens.
To resolve the issue I added RelativeLayout in corresponding xml file in large layout folders.
And it stopped throwing NPE for RelativeLayout when I tested it again for tablets.
Related
I create a Xamarin Forms project in VS 2017 and started by adding a TabbedPage with three tabs. I then added the icons to the Android (in Resources/drawable) and iOS (Asset Catalogs/Icons) projects.
When I start the project on Android it works fine, but on iOS I get an exception that the UIImage cannot be loaded because initWithCOntentsOfFile returned nil. Which is actually correct, because that's not the correct method to use to access Assets. But it's the TabbedPage calling the method, so I cannot do anything about it.
The TabbetPage looks pretty basic.
<?xml version="1.0" encoding="utf-8" ?>
<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:GreenThumb"
x:Class="GreenThumb.MainPage">
<NavigationPage Title="Today" Icon="current.png">
<x:Arguments>
<local:Current />
</x:Arguments>
</NavigationPage>
<NavigationPage Title="Overview" Icon="overview.png">
<x:Arguments>
<local:Overview />
</x:Arguments>
</NavigationPage>
<NavigationPage Title="Settings" Icon="settings.png">
<x:Arguments>
<local:Settings />
</x:Arguments>
</NavigationPage>
</TabbedPage>
And the Asset Catalog looks like this:
This problem seems to be pretty old, but I haven't found any solutions aside some very dirty hacks.
Is there a clean solution out there? Or do I just have to add all my images in the Resources folder instead of Asset Catalogs?
I struggled in the past on this issue. It seems that icons for tabbed pages are not working in iOS if placed in the .xcassets.
I moved those .png files inside the Resources folder and that made the magic.
I suppose it's a kind of bug on Xamarin.
The same error was occurring to me, and I was putting the images on the .xcassets on iOS.
When I placed the images on the Resources folder, they appeared normally on my TabbedPage.
In the official Xamarin documentation about images, they say to put the images in the Resources folder.
iOS - Place images in the Resources folder with Build Action:
BundleResource. Retina versions of the image should also be supplied -
two and three times the resolution with a #2x or #3x suffixes on the
filename before the file extension (eg. myimage#2x.png).
I place all my images in the .xcassets folder, they apparently work well, but it seems not to work on every case.
Its a kind of Chat Screen, Textview contains the image(9-Patch Image) as the Background drawable.
All the devices its working perfectly.
Please refer the Image:
Problem which is encountered is that in Android 4.3 in Samsung S3, the Image(9-Patch) is unable to take the Margin or Padding for textview. The Background Image is not getting stretch to give margin. Please refer Image :
i have tried all margin but it only doesn't reflect in Android 4.3. Is it device specific or Android 4.3 bug?
How can i solve this?
When using a 9-patch image as a background you don't have to set margin/padding to the inner view. The content area of the 9-patch is defined in the right and bottom 1 pixel stripe. Yours image has a content area set on all of it and that results in the behavior reffered in the question.
Try this image with correctly set content area:
So my solution was just to set padding programatically, for instance:
int leftRightPadding = ctx.getResources().getDimensionPixelSize(R.dimen.message_chat_padding_left_right);
int bottomTopPadding = ctx.getResources().getDimensionPixelSize(R.dimen.message_chat_padding_bottom_top);
text.setPadding(leftRightPadding, bottomTopPadding, leftRightPadding, bottomTopPadding);
I am working on Android GingerBread. I'm using the following tutorial:
http://www.androidhive.info/2012/02/android-custom-listview-with-image-and-text/
for the following XML:
http://api.androidhive.info/music/music.xml
The problem is, everything is good except that I'm not getting the image of the first node in my Customized ListView thumbnail.
If someone knows the solution, it would be highly appreciated. I've tried several times cleaning and refreshing the project but no use.
I've created a very simple animation in Adobe Edge Animate that animates a box moving from the bottom right to the top left.
I've imported this file (html + all other files) into my Xcode (v4.5.2) project but get a blank white screen in the simulator. I know my project is fine because if I copy a static html page into the project it renders correctly.
Any ideas?
since the difference between your project and the test page is that your project links to javascript files while the test page did not, maybe you should run a test with a page that calls a simple javascript library.
There are a few threads on adobe forum about some problems with projects opened on ios 6 devices. Maby this also concerns your project.
http://forums.adobe.com/message/4767681
Try to call this method and add some js code to your webview's document:
[webView stringByEvaluatingJavaScriptFromString:#"window.requestAnimationFrame = window.setTimeout;"];
I have images titled like so in my app:
image~iPhone.png
image#2x~iPhone.png
In interface builder I am loading image.png into my UIImageView. I also programatically load some images into a different view using imageWithContentsOfFile. The images all load fine when I run in the simulator but I get no images when I run on the device. If I use the full name of the image in interface builder it works but I want iOS to distinguish between high res and lower res. I have tried a lot of different things but can't figure this out. I see this error in the debugger as well:
Could not load the "image.png" image referenced from a nib in the bundle with identifier "com.mycompany.myproject"
Xcode 4
Deployment Target 4.1
Base SDK 4.3
Thanks for any help.
Ok...so after much experimenting I got it working.
I had two images named:
image#2x~iPhone.png
image~iPhone.png
and I was trying to load them using IB or imageWithContentsOfFile using
image.png
This worked fine in the simulator but not on my device. I just got a blank white screen where the image should be.
I finally renamed the high resolution image to:
image~iPhone#2x.png
Moving the '#2x' modifier after the device modifier(~iPhone) when referencing my images allowed it to work the way I understood that it should from reading Apple's docs. I was under the impression that you didn't need to include the device modifier when referencing images but I had to.
To sum up, I am now using
- image~iPhone.png
to reference my images in IB and programatically for some images. I now get iOS recognizing that I am on a retina screen and loading the #2x images accordingly. So the #2x modifier had to go at the end and the ~iPhone modifier had to be included in the name of the '.png'.
That is what worked for me. Hope it helps someone else. Note that I am only building my app for iOS4.1 and above so there might be some issues with this if you are supporting previous version.
iOS does not automatically pick the right image for the device like that. You are going to have to write code to check which device it is, and set the image by full name.
e.g. if ([[UIScreen mainScreen] scale] == 2) // set hi res image
Or, you can just use the same image in both, and set the content mode to scale to fill. It will look the same.
EDIT: Try writing either ~iphone (lowercase), or just don't write ~iPhone at all on the file name. If your app is not universal, then writing the ~iphone suffix is completely pointless.
iOS file system is case sensitive and device modifiers should be lowercase, it should be
image~iphone.png
image#2x~iphone.png
The #2x comes before the device modifier.
See the resource programming guide