How to program an app to display in full screen? - Android Software Development

Before Android 11, I've adjusted my app to fullscreen easily
My old phone had the camera hole and base buttons outside the screen area, my new phone has a camera hole and the base buttons inside a screen.
With few settings, my app was fullscreen in the old phone.
Styles.xml
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowContentOverlay">@null</item>
</style>​
AndroidManifest.xml
<application
...
android:theme="@style/AppTheme.NoActionBar">
</application>
In my new phone with Android 11, I've searched everywhere on Internet. I've tried many different solutions. In the end, I put in my app the following code in that start of OnCreate().
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
window.attributes.layoutInDisplayCutoutMode =
WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
WindowCompat.setDecorFitsSystemWindows(window, false)
else {
@Suppress("DEPRECATION")
window.setFlags(
WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN
)
}
I wanted a narrow margin near the base buttons and the camera hole, like Chrome.
But all can I get is a wide margin between the app and button (downward) and between the app and the camera hole (upward):
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
But I would want a narrow margin:
similar to Chrome browser for Android:
How can I do this programatically?
I haven't been able to find a single clue to my problem in Internet (and StackOverflow)
I also haven't been able to figure out how to identify if a given cell phone has the camera hole on the screen or if it has the base buttons on the screen. It looks like it's based on DisplayCutout, WindowInsets, boundingRectTop and boundingRectBottom, but there is no real and clear usage example in Internet.

Related

[Q/Help] WM 6.5.x theming (textbutton color)

Hi guys,
I'm very new to theming WM 6.5.x standard themes. I took a standard one and tried to edit them. Pretty easy
The only thing I need help is how to change color to the standard text buttons.
I found this: http://msdn.microsoft.com/de-de/library/ff599682.aspx
I put that REG_DWORD here (as described @ MSDN):
HKEY_CURRENT_USER\Software\Microsoft\Today\<myownthemename>
COLOR_BTNTEXT = ffffff
(Changing the textcolor to white)
BUT: I don't get it to work
Does anybody know what I did wrong?
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
To make it clear: I want to change the textcolor of the button(s) which are labeled as "Löschen/Durchsuchen"
try using an app called UI Tweaker, it could change some system values without big problems (it is possible to export and import the schemes to verify every step in the modifing procedure)
HKLM,"Software\Microsoft\Color","ThemeValues",0x00000001,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,ef,ef,ef,00,ef,ef,ef,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,ef,ef,ef,00,ef,ef,ef,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,ef,ef,ef,00,ef,ef,ef,00,21,30,43,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,21,30,47,00,ff,ff,ff,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,ef,ef,ef,00,00,00,00,00,00,00,00,00,00,00,00,00
Sorry for my English
The role of the color code 56 Group: Select Article options displayed when the current font color, select the state of preparation of the text displayed when the font - the font color (default white FFFFFF)
第56组颜色代码作用: 选择条选择当前字体时显示的颜色、编写文字状态下选择字体时显示的——字体颜色(默认为白色 FFFFFF)
Maybe you can read this article, it teaches you how to be a WM6.5 theme
WM6.5主题制作详细图文教程,全套制作工具,适合任何分辨率
http://hi.baidu.com/kenchan/blog/item/3e083cdb828ebf6cd1164e25.html
Thank you guys, I'll have a look on it
Couldn't get it to work.
I changed the value from:
HKLM,"Software\Microsoft\Color","ThemeValues",0x00000001,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,ff,ff,ff,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,ff,ff,ff,00,ff,ff,ff,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,ff,ff,ff,00,ff,ff,ff,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,55,aa,11,00,ff,ff,ff,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,ff,ff,ff,00,00,00,00,00,00,00,00,00,00,00,00,00
to:
HKLM,"Software\Microsoft\Color","ThemeValues",0x00000001,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,ff,ff,ff,00,00,00,00,00,00,00,00,00,ff,ff,ff,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,ff,ff,ff,00,ff,ff,ff,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,ff,ff,ff,00,ff,ff,ff,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,55,aa,11,00,ff,ff,ff,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,ff,ff,ff,00,00,00,00,00,00,00,00,00,00,00,00,00
but there's no effect on it
Are you sure, it's the right reg-entry?

[Solved] Background Image Quality

I wanted to give my App a nice "Web 2.0" background like the new Twitter for Android has.
When I set the image as "Background" everything looks fine in Eclipse but on my Desire the image gets blurry and distorted.
kinda like this:
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Here is the solution:
Basicly I created a bitmap and used it as background.
1. create a xml file within /res/drawable ... lets name it bg_texture.xml for this example.
Fill it with this code, lets assume the image is called backgroundimage.png
Code:
<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/backgroundimage"
android:tileMode="repeat"
android:filter="true"
android:dither="true" />
2. Set the "Background" property of the element to @drawable/bg_texture and it should work.
You won't see it in Eclipse, but on the phone it looks nice and crisp.
I see a minor difference i guess. You could just save a slice of their bar... like a 1 pixel wide slice, and just set that as background, and itll stretch across?
Does your image use an alpha channel? That might make it look smoother.
its not the fault of the image I guess, because it looks nice in the editor and other images on Android look nice as well... I guess its a bug in the way Android builds the UI. Kinda similar to the bug with artefacts on wallpapers. So I hoped anyone would know a workaround.
Yay I got the solution. It's from this website.
Edit: I updated the first post with the solution.

[Q] Spinner help, Eclipses throwing errors!

I'm having trouble populating my Spinner, so I'm using the tutorial on Google website,
http://developer.android.com/resources/tutorials/views/hello-spinner.html
When I get to part 4, and I put the code in the the java folder, a bunch of red X's pop up, giving me errors.
My questions is do I delete everything in the oncreate () .jave file and insert the code from Googles site? When I do it give me errors, this is what happens,
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
I'm know my coding is wrong, can anybody point me in the right direction?
Hold your mouse over that first "Spinner" that is underlined....I bet you get a hint
You're missing a closing '}' tag at the end, it looks like your missing a spinner called "spinner" in your main.xml and it looks like you've not imported 'Spinner' or 'ArrayAdapter'.
I do have a Spinner in my main.xl, I don't have an arrayadapter though
Ok, I fixed 2 parts of the Spinner issue in the first error line,
I imported a Spinner like Root said, than the second error was it was looking for:
findViewById(R.id.spinner);
Than I realize my spinner is not called 'spinner', it was 'spinner1", so I put the 1 on and the error when away.
Now my next issue is the arrary adapter. I know I don't have one in my main.xml, but based on how far im in the tutorial I havent gotten to the part yet which is #5.
EDIT: It's telling me to "Now create a nested class that implements AdapterView.OnItemSelectedListener. This will provide a callback method that will notify your application when an item has been selected from the Spinner."
Where do I implement that?
Bump, please!

Help plz

I have an android app.I have a preference in my app which allows a user to enter his desired storage location for video recording it can be internal or external now the question is how can i determine if the user has entered the correct storage location path if he didnt enter the right path then how to show a toast and reset the path.
This is the preference
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
This is the editext
Now if the user enters wrong path for example there are spaces in the path or the path is incorrect for video recording how can i check that
Without seeing some code it would be difficult to show you a way that would be easily integrated in to your app.
zalez said:
Without seeing some code it would be difficult to show you a way that would be easily integrated in to your app.
Click to expand...
Click to collapse
Yep, and when is it the "right" path?
The right oath is where a video recording file can be created it can be internal or external
If you've got a file object, you could check these:
Code:
boolean isFile = myFile.isFile();
boolean isDirectory = myFile.isDirectory();
I would implement a chooser instead of relying on your end user to type the correct path.
Take a look at this:
http://www.codeproject.com/Articles/547636/Android-Ready-to-use-simple-directory-chooser-dial
zalez said:
I would implement a chooser instead of relying on your end user to type the correct path.
Take a look at this:
http://www.codeproject.com/Articles/547636/Android-Ready-to-use-simple-directory-chooser-dial
Click to expand...
Click to collapse
Oh, you're right. Much more fool proof. :good:

[Q] How to create a slider ON AN image

this is what I am trying to achieve
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
The black rectangle is an image asset which i need to move left and right on related touch events/drags
Being relatively new to Android , I am finding this difficult to implement.
So was hoping I could get some tips,guides,examples if there are any.
I Have tried viewflipper but that is not what I need here, I tried making a slider like a seek bar , but didn't work out.
Some one suggested that I use a framelayout over the main image to slide but I don't know how to do it.
So any help which will help me out here is appreciated
viv_jen said:
Some one suggested that I use a framelayout over the main image to slide but I don't know how to do it.
Click to expand...
Click to collapse
I've got two ideas on how you can accomplish this and I think a FrameLayout would be the simplest solution.
Simple - Using a FrameLayout. A FrameLayout essentially lets you stack views on top of each other. You would have to put two ImageViews in a FrameLayout and set it up so that the black frame is in the overlaying ImageView while the picture in in the bottom ImageView. Here's a nice tutorial on setting that up. Once that's done, you'll have to set an onTouch listener to the overlaying ImageView and move the view as the user drags it. Use this to get started.
Complicated - Create a custom view. You could subclass view and override the onDraw() to render both your picture and the black frame. You would use the same technique of overriding onTouch() to move the frame. Check out the Android Documentation for more info.
You may use this method from Canvas
Code:
public void drawBitmap (Bitmap bitmap, Rect src, RectF dst, Paint paint)

Categories

Resources