I have two different themes,original and demo. With a click it should switch from original to demo,but with different headlines.
In the Manifest file is the string for the headline declared, but how can I change it from there?
<application
android:allowBackup="true"
android:icon="#drawable/logo"
android:label="#string/app_name"
android:theme="#style/Theme.MyAppTheme" >
I just want to change the android:label.
**may be you can try setTheme(YOUR_THEME); before calling setContentView(YOUR_XML); in activities..'
and you can define theme in your style xml
Related
I'm using Xamarin for an android app on MacOS, my question is very simple but I haven't found anything online and I'm getting mad at this: I just want to set the app style to be Fullscreen and without a title bar so I changed my Manifest.xml as follows:
<uses-sdk android:minSdkVersion="23" />
<application android:allowBackup="true" android:icon="#mipmap/icon" android:label="#string/app_name" android:theme="#android:style/Theme.Material.NoTitleBar.FullScreen"></application>
And when it tries to compile it gives me the following error: No resource found that matches the given name (at 'theme' with value '#android:style/Theme.Material.NoTitleBar.FullScreen')(APT0000)
I tried every other fullscreen theme and no title bar that Xamarin suggests in the drop down menu in the designer but it gives me always that resource error
I just want to set the app style to be Fullscreen and without a title bar
You can add this in your AppTheme:
<item name="android:windowNoTitle">true</item>
<item name="android:windowFullscreen">true</item>
And your application doesn't need to change, just refer to it:
<application android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
</application>
I can't find style/Theme.Material.NoTitleBar.FullScreen in the source code.
hello i'm a new android developer and I create an android app.
when the language of phone is English everything is good but when i change it to a right to left language (for example Persian or Arabic) location of views are changed. what should i do? thanks .
in your AndroidManifest.xml, add the following line to the application node's attributes:
android:supportsRtl="false"
Your final code should look like this
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.app">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="false"
android:theme="#style/AppTheme">
...
</application>
</manifest>
<application
android:allowBackup="true"
android:icon="#drawable/icon"
android:label="#string/app_name"
android:logo="#drawable/logo"
android:theme="#style/AppTheme" >
This is my androidmanifest.xml
and in mainactivity.java i use this lines to show logo in action bar.
getSupportActionBar().setDisplayShowHomeEnabled(true);
getSupportActionBar().setIcon(R.drawable.logo);
after using this two lines in .java file my logo is showing in the display but the app label is gone....
is their any method by which logo & app label both will shown in actionbar after compiling apk.
You not need the two lines in mainactivity.java, you have to select a Theme with the ActionBar:
From res>layout>activity_main.xml(or whatever is the name of the layout of your activity): in the "Design" tab change the theme in "Holo.Light.DarkActionBar" for example.
Or from the AndroidManifest.xml in your app add (or change):
android:theme="#style/AppTheme"
where "AppTheme" is defined in res>values>styles.xml as:
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"></style>
Of course in your manifest you have to define the name and logo in the <application> level:
<application
android:logo="#drawable/logo"
android:label="#string/app_name"
android:theme="#style/AppTheme"
...
Add this into your Activity in manifest.
<activity
android:name=".MainActivity"
android:label="#string/app_name"
</activity>
copy your image file and paste it to the res->minmap folder and then goto your AndroidManifest file and locate the below option
android:icon="#mipmap/image_file_name"
give your icon image file name name here (image_file_name) then run your app.
If i have specified my Theme for the application such as so:
<application
android:name="main_application.GlobalObjects"
android:allowBackup="true"
android:hardwareAccelerated="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
Do I then need to specify the Theme again for each activity defined in the manifest file like so:
<activity
android:name="main_application.MainActivity"
android:label="#string/app_name" >
android:theme="#style/AppTheme" >
</activity>
Or do i only need to do this when over riding the applications theme for a single activity?
Do I then need to specify the Theme again for each activity defined in the manifest file like so
No, Once you have defined the Theme for the application and applied it in manifest <application> tag then there is not need of specifying Theme for each Activity again.
But if you want different Themes for each activity then in this case you can define separate themes for each activity.
Do I then need to specify the Theme again for each activity defined in the manifest file like so
No. If you need a specific Theme for a particular Activity then you can set it on the Activity. Otherwise just set it on the <application>
Activity and Application Themes
If you want to use same theme all over the application then setting theme in application tag in manifest is good enough. For example, this part of your code
<application
android:name="main_application.GlobalObjects"
android:allowBackup="true"
android:hardwareAccelerated="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
But if you want to use different theme in different activities then you have to specify the theme like your code
<activity
android:name="main_application.MainActivity"
android:label="#string/app_name"
android:theme="#style/ThemeForThisActivity" />
If you need different theme for each of your activity then YES.
If you need same theme for your application then NO.
Would it be possible to set the logo and launcher icon dynamically rather than specifying in the manifest
<application
android:icon="#drawable/ic_launcher"
android:logo="#drawable/app_logo"
android:label="#string/app_name"
android:hardwareAccelerated="true">
Call setIcon() and setLogo() on ActionBar to change them at runtime.
EDIT: Works from API level 14 on.