Top bar for app not hiding android - android

I have an app and in the Login screen I have multiple ways to login like gmail, facebook and manual login. They all are working nicely but the problem arises when I try to hide the top bar which shows the app name. I know this has something to do with the theme in the manifest but I haven't set any. Please have a look at my code and see what I am doing wrong ...
Manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.example.spuck"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="23" />
<application
android:allowBackup="true"
android:icon="#drawable/the_spuck_4"
android:label="#string/app_name"
android:theme="#style/AppTheme">
<activity android:name=".LoginActivity"/>
LoginActivity.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:facebook="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.spuck.LoginActivity"
style="#style/Red">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="1"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginBottom="94dp">
<Button
android:id="#+id/sign_in"
android:layout_width="260dp"
android:layout_height="35dp"
android:textSize="13dp"
android:text="Sign In"
android:textColor="#color/white"
android:textAllCaps="false"
android:background="#drawable/signin_button_login_activity"
android:gravity="center"
android:layout_below="#+id/login_button"
android:layout_alignLeft="#+id/sign_in_button"
android:layout_alignStart="#+id/sign_in_button"
android:layout_marginTop="33dp" />
<ImageView
android:id="#+id/app_name"
android:layout_width="100dp"
android:layout_height="100dp"
android:src="#drawable/the_spuck_3_2"
android:background="#drawable/white_with_round"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="30dp" />
<com.google.android.gms.common.SignInButton
android:id="#+id/sign_in_button"
android:layout_width="260dp"
android:layout_height="35dp"
android:layout_marginTop="41dp"
android:layout_below="#+id/app_name"
android:layout_centerHorizontal="true" />
<com.facebook.login.widget.LoginButton
android:id="#+id/login_button"
android:layout_width="255dp"
android:layout_height="60dp"
android:textColor="#ffffff"
android:layout_marginTop="10dp"
android:shadowColor="#000"
android:shadowDx="0"
android:shadowDy="0"
android:shadowRadius="10"
android:layout_below="#+id/sign_in_button"
android:layout_centerHorizontal="true" />
</RelativeLayout>
</RelativeLayout>
AppTheme.NoActionBar.xml
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="colorPrimary">#ff5050</item>
<item name="colorPrimaryDark">#ff5050</item>
</style>

Change the theme of the activity to NoActionBar :
<style name="AppTheme.NoActionBar" parent="Theme.AppCompat.Light.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="colorPrimary">#ff5050</item>
<item name="colorPrimaryDark">#ff5050</item>
</style>

As Nika said, his approach is absolutely correct. What you need to see is that there are 2 types of themes made. One for API 21 and above and the other for API 21 and below. What you need to do is to assign the theme he said to both versions since you want your app to work for both API conditions. See the code below and let me know if it helped ...
for API 21 and above:
<resources>
<style name="AppTheme.NoActionBar" parent="Theme.AppCompat.Light.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">#ff5050</item>
<item name="colorPrimary">#ff5050</item>
<item name="colorPrimaryDark">#ff5050</item>
</style>
</resources>
for API 21 and below:
<style name="AppTheme.NoActionBar" parent="Theme.AppCompat.Light.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="colorPrimary">#ff5050</item>
<item name="colorPrimaryDark">#ff5050</item>
</style>
Now to access this you need to change your manifest to this:
<activity android:name=".LoginActivity"
android:theme="#style/AppTheme.NoActionBar"/>
P.S if you are not sure on how to see the themes for their respective API hold the ctrl button and click on "AppTheme.NoActionBar" text, it will show you two fields where they are to be found and just edit both of them.

Related

RelativeLayout doesn't fill the screen horizontally

I have the following layout:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/fragment_container"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/app_name"
android:text="#string/app_name"
android:layout_centerHorizontal="true"
android:textSize="30sp"
android:textColor="#FF000000"
android:singleLine="true"
android:layout_marginTop="10dp"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:layout_alignParentTop="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</RelativeLayout>
I expected the layout to extend to the edges of the screen, but instead here's what I get:
The declared theme is Theme.K9Dialog:
<resources>
<style name="Theme.K9Dialog" parent="Theme.AppCompat.NoActionBar">
<item name="android:windowFrame">#null</item>
<item name="android:windowBackground">#drawable/popup_background</item>
<item name="android:windowIsFloating">true</item>
<item name="android:windowAnimationStyle">#android:style/Animation.Dialog</item>
<item name="android:windowContentOverlay">#drawable/panel_separator</item>
</style>
Am I misunderstanding what android:layout_width is supposed to do?
This is happening because of <item name="android:windowIsFloating">true</item> in your app theme, should work fine after removing that. Also I am not why you need all those attributes like android:windowFrame and ndroid:windowAnimationStyle in your app theme. If there is no such requirement try using default app theme and add only those attributes to theme which you want to change .

Android: Unwanted White Box at Top of Screen (toolbar?)

How do I get rid of the white box at the top of the android view? I cannot see anywhere in my code where I called something that created the toolbar, nor did I code it myself. It also exists above the view, not in it. I'm guessing there is some setting in the design view of the xml file that can toggle it? Thanks in advance!
** I should also include that it is only on this activity, and my other activities do not have this white bar at the top. Furthermore, the actionbar is the thin blue bar above the white car, so any code that involves manipulating the actionbar will not change the white bar's status. **
EDIT: XML Code is below
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/bucket"
android:theme="#+id/BucketTheme2"
android:backgroundTint="#70FFFFFF"
android:backgroundTintMode="src_over">
<TableLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TableRow>
<TextView
android:id="#+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:paddingBottom="5dp"
android:paddingTop="100dp"
android:text="Find a place to go around you!"
android:textColor="#ff000000"
android:textSize="18dp" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:id="#+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:onClick="randomButtonPressed"
android:text="RANDOMIZE"
android:textSize="20dp" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:id="#+id/bucketBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:onClick="bucketButtonPressed"
android:text="Bucket List"
android:textSize="20dp" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:id="#+id/searchLocationBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:onClick="searchButtonPressed"
android:text="Search by Location"
android:textSize="20dp" />
</TableRow>
</TableLayout>
</RelativeLayout>
EDIT 2: style.xml code for BucketTheme2 is below (I did not post it initially because it only sets colors):
<style name="BucketTheme2" parent="android:Theme.Holo.Light.DarkActionBar">
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
</style>
Set theme for application or activity in Manifest.xml to remove action bar:
android:theme="#android:style/Theme.Holo.Light.NoActionBar"
Or add the following code in Activity in the onCreate method and import android.support.v7.app.ActionBar:
ActionBar actionBar = getSupportActionBar();
actionBar.hide();
Add the following theme to the style.xml
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
Then set this theme to the activity in manifest:
<activity
android:name=".MainActivity"
android:theme="#style/AppTheme.NoActionBar"/>
UPDATE: You can also set the theme as below:
<style name="BucketTheme2" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
</style>
Hope this helps.
Change your activity theme in manifest to Theme.AppCompat.Light.NoActionBar and you should be sorted
Add NoActionBar style in style.xml
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="android:windowFullscreen">false</item>
<item name="android:windowContentOverlay">#null</item>
</style>
And add this theme to your activity from manifest,
<activity android:name=".YourActivity"
android:theme="#style/AppTheme"
>
</activity>
try
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.main);
it should be before setContentView
Just try this in your style
<style name="BucketTheme2" parent="android:Theme.Holo.Light.NoActionBar">
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
I ran into this same issue when using a template project that Android studio already set up. I noticed that in the activity_main.xml file there was unnecessary padding at the top once I changed to a theme of *.NoActionBar. If you remove android:paddingTop="?attr/actionBarSize" it should go away.
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="?attr/actionBarSize"></androidx.constraintlayout.widget.ConstraintLayout>

Simple android app crash after start [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Improve this question
I tried to make a simple android app, that will trigger webserver to open the gate, everything worked just fine till I made some design (not java) changes. Now I cant even start the app properly.
Please take a look and tell me if you have any ideas. It tried the apk # Galaxy S3 and Note 3
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="wstrends.brana" >
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="#drawable/logo"
android:label="WS trends Gatekeeper"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="WS trends Gatekeeper" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
activity_main.xml
<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:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:paddingBottom="#dimen/activity_vertical_margin" tools:context=".MainActivity">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Otevřít bránu"
android:id="#+id/button"
android:layout_below="#+id/password"
android:layout_centerHorizontal="true"
android:layout_marginTop="43dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Pro prokračování vložte heslo"
android:id="#+id/upper"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="29dp"
android:password="false"
android:textColor="#bc000000" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textPassword"
android:ems="10"
android:id="#+id/password"
android:singleLine="true"
android:password="true"
android:autoText="false"
android:layout_below="#+id/upper"
android:layout_centerHorizontal="true"
android:layout_marginTop="39dp"
android:hint="Heslo" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:id="#+id/content"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:singleLine="false" />
</RelativeLayout>
styles.xml
<resources>
<!-- inherit from the material theme -->
<style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar">
<!-- Main theme colors -->
<item name="android:actionBarStyle">#style/MyActionBar</item>
<item name="android:textColorPrimary">#fff</item>
</style>
<!-- ActionBar styles -->
<style name="MyActionBar"
parent="#android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
<item name="android:background">#CA0700</item>
</style>
</resources>
Thanks
Try changing your styles.xml to the following. The theme must be a descendant of Theme.AppCompat:
<resources>
<!-- inherit from the material theme -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Main theme colors -->
<item name="android:actionBarStyle">#style/MyActionBar</item>
<item name="actionBarStyle">#style/MyActionBar</item> <!-- For support lib compat -->
<item name="android:textColorPrimary">#fff</item>
</style>
<!-- ActionBar styles -->
<style name="MyActionBar"
parent="#android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
<item name="android:background">#CA0700</item>
</style>
</resources>
Solution:
no changes in styles.xml whatsoever, but a little change in MainActivity.java fixed this
From public class MainActivity extends ActionBarActivity to public class MainActivity extends Activity

Theme Style don't work on custom LiestView Items

I want to build a theme for my app. But it seems like my LiestView item don't apply the values.
This is the styles.xml:
<style name="AppTheme" parent="android:Theme.Holo.Light">
<item name="android:textViewStyle">#style/TextView</item>
</style>
<style name="TextView" parent="android:Widget.TextView">
<item name="android:layout_margin">8dp</item>
<item name="android:padding">0dp</item>
<item name="android:textColor">#87000000</item>
<item name="android:textSize">18sp</item>
</style>
in my activity i use a Listview with Custom Adapter but the TextViews from my item.xml did'nt have a margin:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:orientation="vertical"
tools:context="de.resper.enigma2chromecast.mainLive" >
<TextView
android:id="#+id/channelName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:text="#string/hello_world" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/hello_world"
android:id="#+id/channelLine1"/>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#android:color/darker_gray" />
</LinearLayout>
what ever you designed xml, put in android manifest file in application theme
<application android:theme="#style/CustomTheme">

scrollview is extremly slow on ics (android 4.0) when containing a long textview

Here's my problem, i'm developing a news applicaiton and i used scrollview wrapping a textview to show the content of the news.
But i found that scrolling is extremly slow on android 4.0 ics when the textview is quite long, and the longer the text, the slower the scrolling is. While on android 2.3 devices things just go as fast as expected.
I don't know whether this is really a system bug cause i found this similar problems reported on the android project
Here's my layout:
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:id="#id/lst_news_details"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/list_background"
android:fadingEdge="none"
android:gravity="center" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginTop="10dp"
android:orientation="vertical" >
<TextView
android:id="#id/tv_news_details_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="#style/Detail_Title"/>
<TextView
android:id="#id/tv_news_details_category"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="#style/Detail_Category"/>
<TextView
android:id="#id/tv_news_details_created_at"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
style="#style/Detail_Time"/>
<include layout="#layout/detail_horizontal_divideline" />
<ImageView
android:id="#id/img_news_details_image"
style="#style/Detail_Picture"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
android:layout_gravity="center_horizontal"
android:contentDescription="#string/image_contentDescription"/>
<TextView
android:id="#id/tv_news_details_context"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_gravity="center_horizontal"
style="#style/Detail_Content"/>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="10dip" />
</LinearLayout>
</ScrollView>
<!-- actionbar shadow -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/action_bar_shadow"
>
</LinearLayout>
</FrameLayout>
And my style.xml
<style name="Detail_Title">
<item name="android:textColor">#color/list_item_title</item>
<item name="android:textSize">18sp</item>
<item name="android:shadowColor">#color/list_item_text_shadow</item>
<item name="android:shadowDx">0</item>
<item name="android:shadowDy">2</item>
<item name="android:shadowRadius">2</item>
</style>
<style name="Detail_Category">
<item name="android:textColor">#color/list_item_category</item>
<item name="android:textSize">14sp</item>
<item name="android:shadowColor">#color/list_item_text_shadow</item>
<item name="android:shadowDx">0</item>
<item name="android:shadowDy">2</item>
<item name="android:shadowRadius">2</item>
</style>
<style name="Detail_Time">
<item name="android:textColor">#color/list_item_time</item>
<item name="android:textSize">14sp</item>
<item name="android:shadowColor">#color/list_item_text_shadow</item>
<item name="android:shadowDx">0</item>
<item name="android:shadowDy">2</item>
<item name="android:shadowRadius">2</item>
</style>
<style name="Detail_Content">
<item name="android:textColor">#color/detail_content_text</item>
<item name="android:textSize">16sp</item>
<item name="android:autoLink">all</item>
<item name="android:shadowColor">#color/list_item_text_shadow</item>
<item name="android:shadowDx">0</item>
<item name="android:shadowDy">2</item>
<item name="android:shadowRadius">2</item>
</style>
<style name="Detail_Picture">
<item name="android:layout_gravity">center</item>
<item name="android:gravity">center</item>
<item name="android:background">#drawable/image_frame</item>
</style>
By the way, i've already set
android:minSdkVersion="7"
android:targetSdkVersion="14"
But haven't set the hardware accelerated flag yet.
Is there any solution? Please help me, thanks!
Well, i've found the solution on my own
just set android:hardwareAccelerated="false" in the manifest.xml
Still quite confused about the reason, waiting for an explanation.
Note that you can add the android:hardwareAccelerated="false" for a specific activity (or even a specific view) as seen here: http://developer.android.com/guide/topics/graphics/hardware-accel.html if you want to keep the rest of your app hardware accelerated.

Categories

Resources