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

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">

Related

Project name bar in main screen

When reviewing my app, I noticed that the blue bar on the top and the text in the bar (the project name) does not fit in the app.
I tried changing the project name into a more relevant one by going into REFACTOR -> RENAME but it said 'can't rename root module.' every time I tried to.
Is there a way I can either delete the blue bar or change the text on it?
Are you familiar with the resources strings object? Let me know if this makes sense... Look at the image that I've included. Go to res/values/strings.xml and make the app_name tag be empty
<string name="app_name"></string>
Project name for Toolbar is defined in res/values/strings with key app_name by default.
In strings.xml, change app_name.
Or there's a setText method on the ActionBar class
To remove the bar depends on the theme used by that Activity (or if you explicitly show a Toolbar in the XML layout)
The name of your app is defined in your AndroidManifest.xml. Inside, you'll see an Application object, with a property of ApplicationName. Set this to whatever you want.
for remove top bar use in Manifest file :
<application ....
android:theme="#style/Theme.AppCompat.Light.NoActionBar"
>
The title of the action bar (your blue bar on the top) is set inside you AndroidManifest.xml, inside the activity tag:
<activity
android:name=".activity.MainActivity"
android:exported="true"
android:label="#string/app_name" >
</activity>
A good practice is to refer to a string stored inside Strings.xml
<string name="app_name">My cool app</string>
getActionBar().setTitle("TITLE");
OR
getSupportActionBar().setTitle("TITLE");

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.

Setting the theme in an android application

I've gone through quite a bit and I'm still at a loss for what I need to do:
http://developer.android.com/design/style/themes.html
http://developer.android.com/guide/topics/ui/themes.html
I have the view set to use the "Dialog" theme in my IDE (IntelliJ IDEA 14.1.2) and the application looks like this in the insepctor:
However looks completely different on my phone (Much larger resolution, but that's not the point).
What am I doing wrong and how can I get this effect?
i use this in one of my activities and it is ok:
<activity
android:name="eddine.charef.mechalikh.swipedemo.mapDialog"
android:excludeFromRecents="true"
android:launchMode="singleInstance"
android:theme="#android:style/Theme.Dialog" ><!--add this-->
</activity>
maybe your android version doesn't support that.
Add to the Android Manifest
<activity
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"/>

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.

Android : How Do I use blank activity?

I'm beginning android programming slowly. I want to blank and white (page of all) theme .So I don't want to see this part of image.
image http://u1311.hizliresim.com/1h/m/upm9r.png
Add below line to your manifest application tag. It will remove from all activities and if you want to remove some of activity just copy and paste below code to activity tag.
android:theme="#android:style/Theme.NoTitleBar"
In your manifest, where the activity is declared, add the "android:theme" as below:
<activity
android:name="yourActivityName"
android:label="your label"
android:theme="#android:style/Theme.Holo.Light.NoActionBar.Fullscreen" >
</activity>
You may want to use this in your Activity
//Delete title bar
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
Add this in your main activity:
requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
Hope this helps.
In your manifest, in the activity tag, write so:
android:theme="#android:style/Theme.Holo.Light.NoActionBar"

Categories

Resources