Fullscreen Mode using ActionBarSherlock on Devices running API <11 - android

Is there a way to go in fullscreen mode using ActionBarSherlock on Devices running API <11?
Further Information:
My app is using ActionBarSherlock and while testing on different devices i stumbled on a problem.
If i try tro launch an activity in fullscreen
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
on a Device running on a API lower than 11 the following error occured:
05-29 10:12:54.436: E/AndroidRuntime(1034): FATAL EXCEPTION: main
05-29 10:12:54.436: E/AndroidRuntime(1034): java.lang.RuntimeException: Unable to start activity ComponentInfo{de.osthessennews.osthessennewsapp/com.example.listview.PlayVideo}: java.lang.IllegalStateException: You must use Theme.Sherlock, Theme.Sherlock.Light, Theme.Sherlock.Light.DarkActionBar, or a derivative.
The error occurs, cuz the Line in the Manifest isn't supported for Devices running on API's < 11.
So i know what is causing the problem, but i dont know how to resolve it. I hope one of you guys can help me.
Manifest Snipped:
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/Theme.Sherlock" >
>

You Can do Programmatically :
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
Use before setContentView().

The latest version of ABS (ActionBar Sherlock) still does not have a Theme.Sherlock.Light.NoActionBar or Theme.Sherlock.Light.NoActionBar.Fullscreen but you can always create a Fullscreen activity by hiding the ActionBar programmatically as explained on the previous answer.
But if you want to create a theme or style, include
<item name="android:windowFullscreen">true</item>
on it, but that will only hide Android's status bar.
To hide the ActionBar in your activities (extending from SherlockActivity or SherlockFragmentActivity) code:
getSupportActionBar().hide();
That will give you a NoActionBar.Fullscreen effect.

Related

Odd PreferenceActivity Theme on Samsung Devices

I'm seeing a very odd theme issue in my PreferenceActivity only on Samsung devices (as far as I'm aware).
-----EDIT (Removed irrelevant code)-----------
The following is an unthemed preference activity:
<activity android:name=".FullSettingsActivity"/>
Setting theme for the FullSettingsActivity:
<activity android:name=".FullSettingsActivity"
android:theme="#style/Theme.AppCompat.NoActionBar" />
yields this:
So clearly the default theme for Samsung devices is rather odd. Is there any reason a PreferenceActivity would end up unreadable like that only on Samsung devices?
Try changing your theme from #style/Theme.AppCompat.NoActionBar to something else like android:Theme.Holo.Light.NoActionBar and see the difference.
Also make sure you add that GalleryTheme in your AppManifest.xml in your application tag like android:theme="#style/GalleryTheme"
Hope that helps.

ResXMLTree_node header size 0x0 is too small in Android Menu

I'm currently setting up an app and stumbled upon some error which I don't understand.
I have a menu XML and provide here two icons.
For the menu in the top right, I want to stick to the standard and use the three vertical dots which go by this name:
ic_menu_moreoverflow_normal_holo_light
Unfortunately though, I get this error:
W/ResourceType(11504): ResXMLTree_node header size 0x0 is too small.
... and my R won't compile anymore.
However It works, for example with
ic_menu_info_details
or
ic_menu_search
Copying the icon itself in drawables didn't work either (?)
Does anyone have an explanation? The exisiting questions don't refer to this.
Here is the full code:
<item
android:id="#+id/menu_send"
android:icon="#android:drawable/ic_menu_info_details"
android:showAsAction="ifRoom|withText"
android:title="Options"/>
The error comes, when I try to incorporate it like:
<item
android:id="#+id/menu_send"
android:icon="#android:drawable/ic_menu_moreoverflow_normal_holo_light"
android:showAsAction="ifRoom|withText"
android:title="Options"/>
Cleaning the code yields that R won't compile anymore.
I just would like to understand, maybe this icon doesn't exist? I googled it though.
After asking google i've found this:
It appears to be that this particular icon wasn't available pre Honeycomb (API 11). I am guessing that you may be getting this error because you're targetting the application to be supported pre-Honeycomb.
Can you try setting this on your manifest.xml:
<manifest>
<uses-sdk android:minSdkVersion="11" />
...
</manifest>

Android actionbar icons always in overflow

I declared my menu items with android:showAsAction="ifRoom". My Activity is extending ActionBarActivity. In preview it is as expected but when run on my phone is it always in overflow.
From what I've seen nothing else is needed. My phone runs in Android 4.4.2 KitKat.
Am I missing anything else?
You have to define your own namespace, if you want to use the showAsAction attribute with ActionBarCompat(I assume you are using ActionBarCompat because you mentioned, that you're extending ActionBarActivity):
xmlns:app="http://schemas.android.com/apk/res-auto"
and use showAsAction like this:
<item [...] app:showAsAction="always"></item>
Just try this...
<item android:id="#+id/action_blah"
android:icon="#drawable/ic_c"
android:title="#string/action_blah"
app:showAsAction="(yourOptions)"/>
(yourOptions):
always = To force to show on the actionbar.
never = Not to show on your actionbar ever.
and
ifRoom = It will let your item if there is enough space on your action bar.
You can see these in Landscape mode.
HappyCoding

Back from launcher icon in ActionBar

I am creating ActionBar using android-support-v7-appcompat. In action bar I have up navigation from logo enabled and its working fine on device with API level 17. But when I run my app on API level 10 device its not working. Please help me. Thanks in advance.
Using following code in activity-
private ActionBar ab;
ab = getSupportActionBar();
ab.setDisplayHomeAsUpEnabled(true);
In Manifest file-
<activity
android:name=".History"
android:screenOrientation="portrait"
android:theme="#style/Theme.Styled"
android:parentActivityName=".MainActivity">
ActionBar is not supported for below API 11 level.Thats why you are getting error.Read this documentation.
To make your code work in lower version, you have to use android-support-v7-appcompat instead of ActionBar.Read the below blog about how to migrate from ActionBar to android-support-v7-appcompat.
http://android-developers.blogspot.in/2013/08/actionbarcompat-and-io-2013-app-source.html
EDIT :
you can download and setup the support library as mentioned here
Below is my explanation based on your updated code,
-To enable up navigation in beginning in Android 4.1 (API level 16),
you can declare the logical parent of each activity by specifying the android:parentActivityName attribute in the element.
-If your app supports Android 4.0 and lower, include the Support Library with your app and add a <meta-data> element inside the . Then specify the parent activity as the value for android.support.PARENT_ACTIVITY, matching the android:parentActivityName
attribute like below example,
<activity
android:name="com.example.myfirstapp.DisplayMessageActivity"
android:label="#string/title_activity_display_message"
android:parentActivityName="com.example.myfirstapp.MainActivity" >
<!-- Parent activity meta-data to support 4.0 and lower -->
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.example.myfirstapp.MainActivity" />
</activity>
For more info read
http://developer.android.com/training/implementing-navigation/ancestral.html
Hope it helps you.

Feature Custom Title: Cannot combine custom titles on API 11 and above

I have a project in which i setted:
minSdkversion setted to 10
MainActivity is a TabActivity
Code in onCreate method is this:
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.main);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.custom_title);
...
With previous settings, all works well! But, if i set minSdkVersion to 11 or above, this exception occurs:
android.util.AndroidRuntimeException: You cannot combine custom titles with other title features
I don't understand why happens this just changing minSdkVersion.
I red a lot about this problem on this site. I tried setting:
Theme.NoTitleBar in main layout and after in Manifest file too
I put those 3 lines in all possible positions
If i comment first line a NullPointerException occurs when i call something on my TextView reference of my CustomTitle layout
I tried setting, in theme.xml file declaration, "windowNoTitle" = true
Since i'm using functions available from API 11 only, i want to set minSdk to 11 before loading App on Store. How can i do ?? I need Help
Edit: With minSdkVersion = 10 and Theme.NoTitleBar in Manifest, same error occurs. Removing it, all works as before.
Can anyone provide a working code (manifest and activity code) for setting a custom title when API is 11 or above ? Thx much
Fixed by my self. I don't know why, but simply adding in manifest file "theme" property for each activity's declaration, all works:
From this:
<activity
android:name=".CheckActivity"
android:configChanges="orientation"
android:screenOrientation="portrait"
</activity>
To this:
<activity
android:name=".CheckActivity"
android:configChanges="orientation"
android:screenOrientation="portrait"
android:theme="#android:style/Theme" >
</activity>
#kinghomer I have tried CUSTOM_TITLE its on 2.2 (API 8) actually. Let me try on API 11 and get back to you!
Before that, you need not make Theme.NoTitleBar anywhere, can be controlled in .java file directly. Give me some time, will be back!
res/values-v11 defalut use this code :
<style name="AppBaseTheme" parent="android:Theme.Holo.Light">
<!-- API 11 theme customizations can go here. -->
</style>
change "android:Theme.Holo.Light" to "#android:style/Theme" will be ok!
tips: if your project no have "res/values-v11", then check your project referenced "lib project" 。
Other than the accepted answer ,there is another way to solve this :
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/CustomTheme" >
assign a theme attribution to application in the xml-based mainifest,that should work for all activities.
This problem occurs when you try to add a custom title bar along with extending your activity by ActionBarActivity or AppcomActivity. These two activity classes already have title bar defined.
So, when you try to add your own custom title bar a conflict arises, which title bar to use - your custom one or the one provided by activity extended.
To solve this issue, just extend your activity by Activity which does not have any predefined title bars, so yours will be accepted without any conflict.
public void MyActivy extends Activity
{
// your code
}
I just added android:theme="#android:style/Theme" in activity in AndroidManifest.xml file and it worked super fine.
<activity
android:name=".MainActivity"
android:theme="#android:style/Theme" >
</activity>
Hope this works for you as well.
In your AndroidManifest file, use this snippet instead of yours.
From this:
android:theme="#style/AppTheme">
to this:
android:theme="#style/custom_title">

Categories

Resources