I have an activity which shows a full screen videoView (yet maintain the aspect ratio). It worked perfectly on Android 2.3.7, but i'm having some weird problems on Android 4 (and probably 3, i didn't check yet):
For some reason, if I set the theme to be full screen, without the titlebar (or action bar), i get a blue-ish (or white-ish?) gradient below the videoView, as shown here:
The relevant layout is here:
edit: on android 3 , it doesn't occur.
When I change the orientation from portrait to landscape, it re-loads the whole video from the beginning. On Android 2.3.7, it continued without any delay, as if nothing has changed.
The relevant manifest part is here:
<activity android:name=".activities.player_activity.PlayerActivity" android:configChanges="keyboardHidden|orientation"
android:theme="#android:style/Theme.Holo.NoActionBar.Fullscreen" android:screenOrientation="sensor"/>
Note that on Android 3, rotating the tablet doesn't do anything, so there is no orientation change.
How should I handle those problems ? The API demos don't seem to be updated to handle those cases.
My project was tested on: nexus one (android 2.3.7) , xoom (android 3) , galaxy S3 (android 4).
In order to fix number 1, I've simply changed the theme that doesn't have any background. Odd that it's this way on the device. Wonder if it's like this on other Android 4 devices. In order to create the theme, I've created a file "theme.xml" in the "res/values/" folder, and wrote there:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.FullScreenNobarsNoBackground" parent="#android:style/Theme.Holo.NoActionBar.Fullscreen">
<item name="android:windowBackground">#null</item>
</style>
</resources>
Of course I've also updated the manifest to use the new theme.
When you change the device orientation, the Dalvik kills the activity and create another, and garbage collector clean all the old stuff.
I suggest to you forces the application stay in horizontal mode, you can do that change the follow attribute in activity:
<activity android:screenOrientation="landscape" />
If you wanna the activy change the orientation, you must handler the change. You can read this documentation how to handling runtime changes.
I'm afraid I can't see the gradient you're talking about on that image. But if it is on the whole screen, then this is probably the standard background for Holo themes and you can just remove it using a custom theme.
As for the restarting on rotation, you could save the current time in onConfigurationChanged(..) and then use VideoView.seekTo(..) to then get it back to the correct time in an appropriate part of your code. However, I don't know why this should happen in ICS because you're not destroying the Activity.
Related
The app itself works completely fine. My question is that on the launching of the app itself, the screen is the Unity default blue for a quick second or so before changing to the black of my first scene.
How do I change this color to be black on startup?
You can change this by going to File --> Build Settings --> Player Settings --> Splash Image --> Background --> Background Color.
From there you can change the background color. You can also change the image, animation type and overlay opacity from there.
Note that there are things you may not be able to change there unless you have Pro license.
EDIT:
Updated to be more detailed of where to change stuff
First change the Splash Image:
There are more options for iOS platform but this settings can still be found in the menu I mentioned above.
If iOS, select iOS as your platform and you can change your Background Color from there:
You should then change the Lunch Screen type from there. Set it to None if you want it to be gone.
If the color does not still change, you can create a Texture with a color of your choice and add it to the Mobile Splash Screen slot:
I believe the OP was looking for the Background Color of the Launch Screens as indicated in these screenshots.
This is taken from an iOS build setting panel. We've observed odd behavior with no textures at all (even though that is what we want), so we use single-pixel, solid-color images as well as a background color to match.
These fields are not made available in the PC/Android build windows, so not 100% sure what the equivalent would be - beyond using flat-colored images. Either way, it is these elements that are used prior to loading your scenes.
I think you are talking about the camera background color. You can set it up in your main camera to black. You can find the camera documentation here.
I am using Android Studio 2.2.1 with project with these settings:
compileSdkVersion 24
buildToolsVersion "24.0.2"
minSdkVersion 16
targetSdkVersion 24
If I use the GUI to change the button background, it adds this to the layout:
android:background="#color/colorPrimary"
Then, if I run the app on a 4.4 virtual device (Microsoft's Android Emulator because I'm on an AMD system and I want a fast emulator), or on a Samsung Galaxy S6 with Android 6.0.1, the button has the correct color but loses left and right padding and the text runs right to the left and right edge of the button.
If I set only the backgroundTint, then the button has the correct padding on the virtual device, but not the correct color. However, on the S6, it has the correct color and padding.
This seems like a bug somewhere, but where? Is it in the code generation or is this a bug in Android 4.4?
I think Android Studio should be doing whatever needed to make it work correct on both platform levels, whether it is as complex as some of these solutions:
Standard Android Button with a different color
or something more succinct.
My styles.xml file shows:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
</style>
</resources>
and my AndroidManifest theme setting is:
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme"
This seems like a bug somewhere, but where?
Right here:
android:background="#color/colorPrimary"
Is it in the code generation or is this a bug in Android 4.4?
No, it is your replacement background. It is a color, without any intrinsic padding, and without being wrapped in a StateListDrawable.
The stock background of Button widgets has some amount of padding enforced as part of the background itself (e.g., via some transparent pixels in the nine-patch PNG used for the background). The actual background itself is a StateListDrawable, which chooses one of several other drawable resources to apply based on the state of the Button (e.g., normal, pressed, focused, disabled).
To replace a Button background, you need to first use a StateListDrawable of your own. Otherwise, your Button will not appear to respond visually to click events or other state changes (e.g., being disabled). Then, you can either incorporate some padding into the backgrounds for your states, or put padding on the Button widget itself, as you see fit.
I think Android Studio should be doing whatever needed to make it work correct on both platform levels
Android Studio assumes that you know what you are doing. There is no hard-and-fast requirement that Button backgrounds have this sort of padding, and there is no hard-and-fast requirement that a Button be something that makes sense to users (versus "hey, why does this button seem to not respond visually when I tap on it?"). There will be scenarios where developers do want Button widgets to have no padding, such as in an implementation of a segmented-list-control sort of compound widget.
Personally, I think the decision to have some intrinsic padding in the Button background is regrettable. But, that's the way it was implemented back in Android 1.0, and Google has elected to maintain the approach, even with newer themes, presumably for backwards compatibility.
If I set only the backgroundTint, then the button has the correct padding on the virtual device, but not the correct color
I have not played with backgroundTint with appcompat-v7. It is possible that you are seeing a bug there. You might consider posting a separate question with a complete example, plus screenshots, to get more specific help with that particular concern.
I wanted to ask about android orientation;
I made 2 different folders for layout: layout and layout-land
when the orientation changes while the application is running i don't want to restart the running activity so i fixed that problem by adding the following line of the manifest file
android:configChanges="keyboardHidden|orientation|screenSize"/>
the problem then is that the app is not switching to the appropriate layout when i rotate the phone
does someone have any idea about the best way to handle the orientation changes of an android application ( i want to keep the state of the layout when i switch )
Simple: Let Android do the hard work.
Saying configChanges="orientation" overrides the default orientation behavior especially if you're using multiple layout files.
Change this:
android:configChanges="keyboardHidden|orientation|screenSize"/>
To this
android:configChanges="keyboardHidden|screenSize"/>
I have made several apps before using eclipse. I (think) always started out with file>new>project>application project and eclipse set up a project in which the main activity was comprised of a black screen with nothing in it - until I used the "graphical layout" editor to start adding some buttons/text etc.
But in more recent versions of eclipse it appears that however hard I try, I always seem to ens up with some components already on my activities screen. It appears that some "style" or "theme" (whatever they are) has been selected in the process and my activity starts with a fat bar across the top with my application's icon on the left of it. I have attempted to make edits to various xml files to remove the unwanted icon/bar, but so far to no avail.
What do I need to do to get a properly blank application so that I can be fully in charge of every pixel on the screen?
In your graphical layout preview select AppTheme select theme select Theme.NoTitleBar.FullScreen
You should see a preview with no title bar
Add this in manifest for your activity
android:theme="#android:style/Theme.NoTitleBar.Fullscreen">
I recently updated my app, changing it's design a bit. Amongst other things, I styled buttons with custom drawables (well - not exactly custom, just taken from ICS release). Everything works well, except for one of the users.
Instead of:
He sees:
This is a Button, but I have also other controls styled with the same background drawable and the problems appears there (so, it's not limited to buttons).
There are two changed style properties that these controls have in common. One is, of course, a background drawable. The other is textAppearance:
<item name="android:textAppearance">?android:attr/textAppearanceMediumInverse</item>
I came to a conclusion, that this user is using some strange theme, which alters the default value of textAppearance* styles. But I have no idea what attribute may control this "text background color" (android:background does not work, checked this just in case). Or maybe I'm looking in the wrong place and this problem is not related to textAppearance?
EDIT:
The background image is a semi-transparent PNG file.
Android version 2.3.7, Motorola Milestone. That's all I got.
EDIT 2, Fixed:
OK, the problem was at the users side, it turned out he was using CyanogenMod7 with forced 16bit trasparency. After switching that option off, everything works.
OK, the problem was at the users side, it turned out he was using CyanogenMod7 with forced 16bit trasparency. After switching that option off, everything works.