I have created a navigation drawer in my project of android 4.1 version. Now I have added backward support to froyo as well in my app using the support libraries. But in the drawer_list_item xml file, it is showing some error in these lines, when I try to run it on gingerbread.
1) android:minHeight="?android:attr/listPreferredItemHeightSmall"
2) android:textAppearance="?android:attr/textAppearanceListItemSmall"
I have found from another website that the line 1 is only available on API 11+ and line 2 is only available on API 14+. So my question is, Is there any other alternative to these two lines of code, which makes my code run on lower version devices such as gingerbread as well. Now when I try to remove these two lines of code from my xml file, the app runs file, but the navigation drawer list items are not properly displayed correctly. So I need an alternative for the lines 1 & 2 for my project. Any help from any one is easily appreciated. Thanks in advance..
because those are values you can replace them by your own custom attributes, to find more about them look at
https://github.com/android/platform_frameworks_base/blob/master/core/res/res/values/themes.xml#L123
which you can find corresponding values. you can create your own attribute files to run on any device without
any version restriction by using the values from above link and creating XML attribute file. in order to find
how to create attribute file look at google doc.
Related
I managed to get my adaptive icons working by creating a folder mipmap-anydpi and placing suggested xml file there (https://developer.android.com/guide/practices/ui_guidelines/icon_design_adaptive.html#studio)
This worked on api 26, but broke icons on android versions lower than that, they now show default android image. I managed to fix this by renaming my folder to mipmap-anydpi-v26, now icons work as expected on all supported apis.
My question is this, are we supposed to do it like this? Will -v26 make it also work on api 27+ or I have to create separate -v2X folder for each future api?
When you create a folder or a ressource file for a specific screen density or android version, this file becomes, in your case, the default reference for this version and the versions above.
Hope this helps.
I have made a programm based on SDK 7. Now I want to add an Actionbar to it. I changed the minSDK to 11 in the Manifest. Isn't that supposed to change the design of the layouts I already have?
Problem is, that I get returned "null" by getActionbar(). I read, that I have to activate the title bar in the OnCreate of the mainactivity. But that does'nt change anything, still "null".
I can see the titlebar, but on SDK 7 it's smaller than on SDK 11. Can't really describe my problem. I just want to use Actionbar on my old written App. But the Layout still looks like in the pic below (left).!
LayoutProblems
Hope someone can help me.
Thanks!
You should also replace the old android.jar with the new one from SDK 11 to get the new GUI. If you are using eclipse for development, just check different Project buid target under Project - Properties - Android.
If you want to use ActionBar in older devices you must use actionbar support library which is provided with the sdk.
I'm developing an API for Android and it works great but I'm not sure how to package/distribute it. I've gotten the "meat" of the API into a jarfile - that's all the classes and an XML file in res/values/attrs.xml (I'm not sure if there's a way users can reference to that without having to copy my attrs.xml into their /values folder, but that's another question).
While trying my API in a test case, I've added my .jar to the build path and I can import a class successfully if I want to, but I don't want to :P My API allows users to implement a custom View into their own XML files, so nothing is instantiated in code.
The question: How can users reference to a custom View in my API? For example, if my View is called FooView and is in package com.myfoo, the following XML fails to load:
<com.myfoo.FooView
android:layout_width="fill_parent"
android:layout_height="100dp"
/>
Does this have to packaged into a jar , As i see facebook android sdk they give out the source code . I set it up as a new android project and from my android project reference this as library.In that case i am able to access all the apis exposed
You might want to look into Android Library Projects. These are basically normal android projects, which can be referenced as a library. This means you can define classes, layouts and resources as you would normally, and just use them in your main app (in this case in your clients app) as if they were defined in the same project. This allows you to reference views in XML like you tried above via <packagename.classname ... />.
There is one huge downside though (which is especially important when you create custom views):
styleable-resources simply don't work. This is a bug.
According to this question it's going to be fixed in the next devtool release though.
With that in mind I recommend setting up a small test project with a test library project and see if everything that you need works correctly.
When I first started a project in Android under eclipse, I am able to access the Graphical Layout designer, so I fast can design my application. But when I create a new XML file in order to add components to another class I can use this feature, how can I fix this?
Sometimes when you have a project with, fore example, 2.1 with google apis the editor dont work property. Delete the google api and try other time
I've written a relatively simple app, and I've been testing it out on the various different API levels created through the SDK and AVD manager in Eclipse. It works great in all API levels except for level 3. I have a few spinners on the front page which work just fine, but my four buttons don't seem to be working. I've tried adding a breakpoint in one of the 'onClick' methods that I specified in my xml layout file, but the breakpoint never seems to get reached. I'm kind of at a loss here. Does anyone have any idea what could be going on here?
Level 3 does not support the onClick attribute in XML. Unfortunately, you'll have to wire up OnClickListeners in code.
... or drop support for 1.5. It's a small and shrinking part of the market.