change android label name and gravity in androidmanifestfile - android

Hi i have to developed one sample app.Here i wish to select the app name is Admin Login and gravity is center.here i have to run the app means the app name is diplayed successfully.but the gravity is not worked for me.here i wish to align the app name is center.how can i do.please give me solutions.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.androidlogin.ws"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="8" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<activity
android:name=".AndroidLoginExampleActivity"
android:label="Admin Login" android:theme="#style/CustomTheme" android:gravity="center">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Edit:
<style name="CustomWindowTitleBackground">
<item name="android:background">#093f7c</item>
<item name="android:gravity">center</item>
</style>
<style name="CustomTheme" parent="android:Theme">
<item name="android:windowTitleSize">35dip</item>
<item name="android:windowTitleBackgroundStyle">#style/CustomWindowTitleBackground</item>
</style>

I have checked your styles. There you specify
<item name="android:gravity">center</item>
for CustomWindowTitleBackground. Its not possible because setting gravity center means it will align in center to its parent. so there is no possibility of giving the layout width to fill_parent.
so i think you must use custom xml file and align your title

Define a custom title style/theme.
Als o check com.example.android.apis.app.CustomTitle.

Try to set gravity in AndroidLoginExampleActivity.xml file
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:gravity ="center" >
or if you want to use gravity in sub layout then use layout_gravity in sub layout.

Related

How to make android layout background transparent?

How to make RecyclerView item background transparent I need to show background image?
I tried 3 solutions given in Stack Overflow and not worked for me
1 : android:background="?android:attr/selectableItemBackground"<br>
2 : android:background="#android:color/transparent"<br>
3 : alpfha 0.4
udated i also tried
4: android:background="#null" (Answer from this post) and not working
full xml code
Try to give this on your item CardView
app:cardBackgroundColor="#android:color/transparent"
Try this:
1) In your manifest make that activity theme to Transparent-
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.androidhub4you.transparent.background"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<application
android:allowBackup="true"
android:icon="#drawable/logo"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.androidhub4you.transparent.background.MainActivity"
android:theme="#android:style/Theme.transparent"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
2) Now your page will be 100% transparent, so if you need some background color then set opacity like-
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#80000000"
tools:context=".MainActivity" >
it helps you.
So for the layout you are inflating for the item you can use
android:background="#null"
You can also use developer options on your device to see layout bounds or check the view hierarchy to see which item is giving you problems
First add this style in styles.xml
<style name="Theme.Transparent" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">#android:color/transparent</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:windowNoTitle">true</item>
<item name="android:backgroundDimEnabled">true</item>
<item name="colorPrimaryDark">#android:color/transparent</item>
</style>
then add this line in AndroidManifest.xml below the corresponding activity
android:theme="#style/Theme.Transparent"/>
hope it helps.
set all layout backgrouncolor= '#00000000' also to your Recycleview background color to achieve this view
set transparent color in your view
#80000000

tool bar not removed?

So im trying to remove my tool bar on android design page but can't for some reason.
XML code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent"
android:layout_width="match_parent">
</LinearLayout>
Did you set the theme of your Activity in your Manifest without an ActionBar?
In styles.xml:
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
And in your AndroidManifest.xml:
<activity
android:name=".MainActivity"
android:theme="#style/AppTheme.NoActionBar" />
Then in your design page, you'll need to select the theme you just created in the dialog.
Add this in manifest file
<application
...
android:theme="#android:style/Theme.Holo.NoActionBar.Fullscreen" >
...
</application>

Android- ActionBar hidden in emulator but showing in XML layout

I used getSupportActionBar().hide(); The result is as expected, action bar hidden during app testing but in XML design view its still visible and thats a problem because i need to visualise how the app looks. Any way i can make it disappear in the XML design view?
That's happening because you are programmatically disabling actionbar, and your IDE doesn't know if it happens or not.
Add this to res/values/style.xml (create one if you don't have one)
<style name="AppThemeNoTitleBar" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowNoTitle">true</item>
<item name="windowActionBar">false</item>
</style>
and put this under application tag in AndroidManifest.xml
android:theme="#style/AppThemeNoTitleBar"
so from the scratch (assuming you don't have anything, it should look like this.
res/values/style.xml
<resources>
<style name="AppThemeNoTitleBar" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowNoTitle">true</item>
<item name="windowActionBar">false</item>
</style>
</resources>
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.myapp" >
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppThemeNoTitleBar" >
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
I think you have theme for your activity in your manifest. if you remove your theme that contains the actionbar, problem is solved.

Android XML: Text Color does not change?

however my text color will not change it's color to black.
I don't know what the problem could be... do you have any idea?
<TextView
android:id="#android:id/empty"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#000000"
android:textColorHint="#000000"
android:textSize="14sp"
android:color="#000000" >
EDIT:
My manifest is that:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.blabla.blabla"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="11" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
>
<activity
android:name=".blablabla"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
my styles.xml is empty
<resources>
</resources>
EDIT:
i think i solved my problem..
the solution: Android ListView Text Color
i aded a style:
<style name="ListFont" parent="#android:style/Widget.ListView"> <item name="android:textColor">#000000</item> <item name="android:typeface">sans</item> </style>
and added it in my manifest...
in my activity i used this:
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(getActivity(), R.array.BlaBla, android.R.layout.simple_list_item_1);
i ask myself what exactly "android.R.layout.simple_list_item_1 does? - why my textColor did not worked and why it does work now with a seperate style - do i need to mention simple_list_item_1 then in my activity any more?
thx u guys

Android overdraw background. How set correctly?

I know there are many topics with the same request but I can not fix the background problem for my application.
If I write the code like this:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top|center"
android:orientation="vertical"
android:background:"#drawable/wallpaper>
I receive the error Lint: "Possible overdraw: Root element paints the background...."
So I changed with this:
style.xml
<style name="AppTheme" parent="#android:style/Theme.Holo">
<item name="android:windowBackground">#null</item>
</style>
<style name="WallpaperTheme" parent="#style/AppTheme">
<item name="android:background">#drawable/wallpaper</item>
</style>
manifest.xml
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:hardwareAccelerated="true"
android:allowBackup="true"
android:theme="#style/AppTheme">
<activity
android:name=".Main"
android:label="#string/title_activity_main"
android:theme="#style/WallpaperTheme">
...
...
</activity>
In this way no longer receiving the error Lint but the layout of the application is wrong, for example:
Also the buttons do not follow the correct layout ...
How do I do then?
I'm stupid!
I changed the code in this way, and the error of Lint no longer appears:
style.xml:
<style name="AppTheme" parent="#android:style/Theme.Holo">
<item name="android:windowBackground">#null</item>
</style>
manifest.xml
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:hardwareAccelerated="true"
android:allowBackup="true"
android:theme="#style/AppTheme">
<activity
android:name=".Main"
android:label="#string/title_activity_main">
...
...
</activity>
layout.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="top"
android:orientation="vertical"
android:background="#drawable/wallpaper">
Do you really need to change the app theme ? It seems to me that you just wanna change the background of the activity and put the layout background as the activity background... Why do you
change app theme ?
change windowBackground and not only the background ?
Here, you basically change the container/parent of the layout itself by setting it to a null decorview. You don't need this and that is what affects the placement of the linear layout.

Categories

Resources