how to add logo with app label in android studio - android

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

Related

Xamarin.Android No style resource found

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.

Android activity theme changes every time I restart Android Studio

Every time I restart Android Studio, the theme of all the activities get changed to either "Theme" or "Light", whereas I want to keep the theme as "AppTheme.NoActionBar".
I have included the line:
android:theme="#style/AppTheme.NoActionBar" in my android manifest file.
Be sure which theme is defined in you mainifest, in the part where you define your application:
<application
android:name=".ExampleApp"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme.NoActionBar">
...
This is the theme of your application, if you want a specific theme in your activity, you have to set:
android:theme ="#android:style/AppTheme.NoActionBar"/>
into your activity tags:
<activity
android:theme ="#android:style/AppTheme.NoActionBar"/>
...

Do I need to specify the theme for each activity in the AndroidManifest.xml

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.

How to change headlines of a theme with a click?

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

how to Remove the space for showing Application name

I developed an application. I would like to remove space that is used
for showing application name on top of my application UI. (The Title Bar)
I set Application label as null In manifest File But it will not remove the space for showing Application name
Please tell me what is the correct or possible way to do that
Thanks in advance
You request window feature in your onCreate method:
#Override
public void onCreate(Bundle savedInstanceState) {
requestWindowFeature(Window.FEATURE_NO_TITLE);
super.onCreate(savedInstanceState);
}
or in AndroidManifest.xml:
<activity android:name=".YourClassName"
android:theme="#android:style/Theme.NoTitleBar">
</activity>
i think you can add this line in you application tag in android manifest file
android:theme="#android:style/Theme.NoTitleBar"
For android studio:
In android AndroidManifest.xml file change the theme like: android:theme="#style/Theme.AppCompat.Light.NoActionBar"
example
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/Theme.AppCompat.Light.NoActionBar" >
you can use this style
<style name="MyTheme" parent="#android:style/Theme.NoTitleBar">
<item name="android:windowNoTitle">true</item>
<item name="android:windowBackground">#drawable/xyz</item>
</style>

Categories

Resources