Project name bar in main screen - android

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

Related

Android studio #strings not working

In my android project none of my #string variables are not working.
For example in the title bar I see #string/app_name instead of myapp.
In my AndroidManifest.xml it looks normal, with the line android:label="#string/app_name"
Also, in my layout buttons and textviews show #string/action_sign_in but they also have the line in there xml layout. android:text="#string/action_sign_in"
Anyone had this issue before?
Clean, rebuild verify if its working.
If not, you can alt+enter on the #string/action_sign_in redline and click on create string value resource then set the value to the string.

Can I set android launcher icon in Main Activity

We always know set android:icon in Manifest can set icon and logo,
android:icon="drawable resource"
Can I set logo icon in Main Activity with Java code?
thanks for help
This answer could help you.
Extract from mike yaworski's answer:
Summary:
android:icon="#drawable/ic_launcher" determines your launcher icon, so
just add images to the drawable folders and change ic_launcher to
whatever the name of image is that you want to be the icon.
android:label="#string/app_name" determines your "label" so just look
for app_name (because the label is referenced to #string/app_name) in
your strings.xml file and change the contents of app_name.

Android Change the app name and logo

I am new to android programming.I have started building an app using eclipse.In the layout file the app icon and App name comes there by default. How do I change it.
A relative layout is there by default.
Whatever I add say--image view textview get added below the main title bar.
How do I change this?
Links to app name and icon are placed in the AndroidManifest.xml inside the application tag. String resources, like #string/app_name, are placed inside the strings.xml file in the res/values directory. Drawable resources, like #drawable/ic_launcher, are inside the res/drawable set of directories. Good luck!
try This
For Logo
android:icon="#drawable/icon"
For Application Name android:label="#string/app_name"
As already pointed out by Egor, you must change the appropriate string in your strings.xml. Typically, the key name in the strings.xml is by default app_name. Change this to whatever you wish to change your App's name to.
For your App's icon, I would recommend using this website to create the appropriate resources: http://android-ui-utils.googlecode.com/hg/asset-studio/dist/icons-launcher.html. This saves the trouble of creating different size resources. It gives you all of them in on go. Once you have downloaded the new set of icons, just replace the old set of icons with the new set. Take care of the name though. Again, typically, the app icon has the name ic_launcher.
Simply U have to change in Androidmanifest File in application tag which include property like For change logo use android:icon="#drawable/icon" property and change drawable image as per your requirement and for change application name use android:label="#string/app_name" property and write at string.xml file in app_name label put appropriate name for that.

How to get a reference to the TextView that displays an app's name

I want to get a reference to the TextView that displays name of the app. E.g. I have code like this in AndroidManifest.xml:
<activity
android:name=".Jain_aartisActivity"
android:label="#string/app_name" >
and I want to get reference to the TextView that displays the app_name string.
If you just want to get the view and replace it with your own then try the below code.
activity.getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE,
R.layout.your_layout);
activity could be this if called from within the activity.
Edit: It worked but you have to have a unicode font on your device/emulator. Well I cant say for all devices but mine have the font pre-installed and below are the snapshots.
my strings.xml file contain
<string name="app_name">जैन आरती संग्रेह</string>
Edit 2:
If you have the typeface with you then just create a small layout that looks like title bar and use the above mentioned code to replace the default title bar with yours.

How to add TitleBar in this android example?

I am new to implement the ListView with section.
I have use this application to implement the section to my list view.
Now I want to add the Titlebar that display the application page title. Then where do I have to make a change? In the xml file or in the Java file?
Please refer the example and let me tell what should I have to change to make Titlebar for my app.
Try this...
final Activity activity = this;
activity.setTitle("Settings");
if you disabled the title bar using, this.requestWindowFeature(Window.FEATURE_NO_TITLE);
remove it.
(OR)
Try this..
final Activity activity = this;
this.requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.settings);
activity.setTitle("Settings");
There are two ways to change title bar for your activity:
Design time (that is, change title in AndroidManifest.xml file).
By coding (that is, you can code to change the activity title).
Example for 1st:
you can Change the Title of each screen (i.e. Activity) by setting their Android:label inside the AndroidManifest.xml file:
<activity android:name=".Hello_World"
android:label="This is the Hello World Application">
</activity>
And yes, to display customized title bar for your activity, go through this answer: How to change the text on the action bar
In your AndroidManifest.xml file you have a section for each activity that looks like this
<activity
android:label="Your Activity"
android:name=".YourActivity" />
where the android:label tag defines what the text in the titlebar is.

Categories

Resources