I work with FireMonkey in C++Builder, and I'm trying to make a transparent form, so that the components that are on it are displayed, but in the space where there are no components you can see what is below the form (transparent)...
I have set the Transparency property of the form to true, but the areas of the form that should be transparent look BLACK.
I have searched the Internet and found solutions for Delphi, but none for C++.
I tried to include this in the manifest:
SetActivityAttribute(MYFormTransparent ,android:theme, #android:style/Theme.Translucent.NoTitleBar)
but still, the same issue.
Any ideas?
This is a known problem that was introduced in 10.3 Rio. It has already been reported to Embarcadero (unfortunately, it has been closed as "works as expected"):
RSP-22314: Transparency Property
Marco Cantu commented on that report:
Sorry for not commenting sooner. We have done some research on it for the last update, but decided to defer a fix.
The core issue (in short) is that we use Android SurfaceView and this is a limitation of that platform control (only 2 SurfaceView instances are available). We are using this platform element as it allows us to mix styled and platforms controls (a feature we introduced in 10.30). By chancing the internal implementation, the transparency become unavailable.
There is an alternative implementation of forms via TextureView, but so far our tests have shown that the speed of rendering 2 times slower, and we don't want to slow down all FMX applications on Android for this feature.
There are some workarounds, one of them is to use a frame instead of a form. It works perfectly with transparency and uses less resources than separate form.
For existing code the fast way is to add a Layout to the form and have the controls inside it. When you need to display the form with transparency you can just move Layout from the specific form to main form as a child and align it on content Align = Content.
Other commenters noted:
I tested an alternative with formStyle = popup and stylelookup = popupboxstyle
with a rectangle in the form with transparency = 0.4 and some instructions to size the form with setBounds
The result is acceptable
As said by Herve Escriou, a work around is to set your formstyle property of the form to "Popup". This will make the form transparent again. But this wil have the effect of the wsMaximized style not working properly. You can go around this by making the following code additions to your form: ...
Related
Now that it's 2022 and Android tablets (and their cousins, foldables) are getting more prevalent, I got my interest ramped up in building a better tablet version of one of my apps. Coming from iOS, there is a useful layout feature that one can use when designing tablet UIs called "readable content guide". Apple describes it as follows:
This layout guide defines an area that can easily be read without forcing users to move their head to track the lines. The readable content area follows the following rules:
The readable content guide never extends beyond the view’s layout margin guide.
The readable content guide is vertically centered inside the layout margin guide.
The readable content guide’s width is equal to or less than the readable width defined for the current dynamic text size.
A picture is worth a thousand words. To the right is some text aligned to the readable content guide (the left version just spans the width of the main view):
Looks great when reading long-form content, doesn't it? Thus, my question:
is there a standardized version (that is, without me having to code one myself) of a feature similar to this on Android?
Now that version 12L is out, I thought it would incorporate something like this, especially with Google promoting Jetpack Compose (and other new UI extensions) as a faster and easier way to build UIs.
If you know what a comfortable width is you can use android:maxWidth="yourWidth" to limit the width of your textview to what you want
I want to change pixel color via android application using background.
It means entire screen, not image file.
How can I modify pixel color?
Result of searching, I could find "Bitmap", "Surfaceflinger", "Framebuffer".
but, I don't know what is correct way.
The concept SurfaceFlinger and Framebuffer is a low level concept in Android system. In application level, which built on framework, these concepts are opaque.
As Bitmap, it's not very necessary if you just change the background color.
You can just simply do like following in your Activity.
getWindow().setBackgroundDrawableResource(R.color.color_res_id);
// or change the root view background
getWindow().getDecorView().setBackgroundResource(R.color.color_res_id);
If you are novice in Android app development, you can start reading the training here, it's a good source for beginner to start.
I'm stepping through "Professional Android 4 Application Development". I'm working on the "ToDoList" example in chapter 4, and to the point of implementing a custom view for the list item. When I run my version of the app, the custom view renders its background color, but the margin line and the text don't appear to render. I've compared my version against the version from the code bundle, and I only see what seem like inconsequential differences, but there must be something subtle that is different.
I obviously want to fix the problem, but something like this is a better lesson on how to figure out what's wrong, but I just don't see it.
I wish I could just zip up the two apps and attach them here, but that doesn't appear to be an option. I did upload my sample app to a shared Google Drive folder, which is included here. I believe I've made it public so that other people can download it.
If someone reports that they can't get to it, I guess I'll just try pasting in the relevant source files here.
...and I only see what seem like inconsequential differences, but
there must be something subtle that is different.
There is a difference that is quite important. In your init method you initialize the float margin variable like this:
margin = myResources.getColor(R.color.notepad_margin);
But, from looking at your code(where you draw the lines) the margin variable seems to be the point at which you draw the vertical lines(in your case margin will be something big and out of the screen). Shouldn't this be:
margin = myResources.getDimension(R.dimen.notepad_margin);
Also, you may want to increase the stroke width to see those lines:
linePaint.setStrokeWidth(3.0f);
I am developing a mobile site, so I'm using CSS to make things as liquid as possible.
I'm having an odd difficulty. Within a div container, I have a <p> that is supposed to fill the width of the div. I've tried width:auto, width:100%...nothing seems to work on Android Browser. Here are examples:
iOS (Correct):
Android (Incorrect; not fully spreading; added more text than iOS version so you can see what I'm talking about):
Both screenshots taken from respective emulators.
Here is the odd thing, though... If I give the class applied to these <p>'s a background color, the Android browser then allows the <p> to fill the full width of its parent div (looks identical to iOS). The really odd part, though, is that if I make the background color transparent (I thought I had it tricked lol), then it goes back to doing as shown in the example.
So, I have a <p> only properly referencing its CSS if it has a background-color applied... am I stupidly overlooking something, or is this some issue with Android Browser? Any ideas how to fix it?
Thanks for your time.
While it may not be the best solution, I finally just made an "invisible" transparent png and set it as the <p>'s background, and that fixed the issue... if you can call it fixing. :) I have to assume it is some kind of error in Android's Browser, as I tried this in every browser, desktop and mobile.
It is the intended behavior of Android phones. It will enhance the readability of copy text, since you are not forced to scroll sideways if you pinch zoom the page.
It can be managed on your own phone maybe in the browser's settings, but that is not the solution you want.
It can be 'fixed' by the workaround of applying a background-image to the element you want.
This can be done with a base64 encoded data url:
background: url(data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7);
In your mobile browser's settings, look for something called "Auto Fit Pages" and disable it. This setting (in Android) is ON by default. Turn it off and your text will flow as it should.
the div or any element above this could be the issue.
if you give fixed width to the p element, does it work well ?
I am trying to implement the minimumfontsize property in android. This is common to the ios sdk. Since it is not presently available in android I was wondering if anyone can help me with a similar implementation in android?
To be more specific, I am trying to implement this property for the TextViewUI in android.Hence I basically need to implement it for this widget.
These are the ios specs of this feature:
"When drawing text that might not fit within the bounding rectangle of the label, you can use this property to prevent the receiver from reducing the font size to the point where it is no longer legible.
The default value for this property is 0.0. If you enable font adjustment for the label, you should always increase this value. This property is effective only when the numberOfLines property is set to 1."
Without knowing what you intend to do with the code, there isn't much help to be had. The closest thing to what you describe in android is setting device independent pixels (android:textSize="30dp"), which ensure that however big (or small) the text looks on your handset, it will look pretty much just like that on all other handsets, at least those of the same size/density. See R.attr and Supporting Multiple Screens