toggle button height less than 30dp text disappears Android - android

I am having quite a challenge with this. If the toggle button height is less than 30dp, the text disappears.
I am wondering is this a design issue or can anyone help me with a workaround?

You could try setting the padding to 0. Sometimes you need to override the default padding.
If that doesn't do the job you can use custom graphic instead of android default graphic. The default toggle button graphic for android is 9-patch and in this there is some build in padding you can't disable from code.
You could try to setIncludeFontPadding to false. This can be done both in code and xml.
As a last resort you have to change the textsize in order to fit inside the button.

Related

Set background for FMX popup window

I have an FMX Android project compiled with Delphi 10.1 Berlin. The user needs to select from 19 values to run it and I use a TPopupBox component to display 19 TRadioButtons that show in 3 columns of 7+7+5 buttons for that selection.
The default is for a transparent popup window which is useless, so I edited the style to add a white TRectangle to the background of the popup window which works, but only if I size the rectangle to match the size of the popup. Aligning the rectangle to client or contents only sets an opaque background to the first row of radio buttons. I have 2 questions:
How can I auto size the rectangle rather than fixing it at design time to match what I calculate will be set for popup.bounds?
Is adding a TRectangle to the style background the best way to get an opaque control?
I have tried all obvious align options and searched the internet. Somebody suggested deleting 'background' from the style list but that did not work. Somebody else suggested editing the manifest but my manifest just gets overwritten when I compile.
I believe you wrote erroneously TPopupBox and probably meant to write TPopup. That is anyway what you should use for popup windows.
You may want to create a new project, for testing purposes. Add a button near top left. This will show and hide the popup window.
Add a TPopup and size it as you wish, and set Visible := True.
Add a rectangle inside the popup and set its Align property to Contents. Set its Fill.Color property as you wish. Add TRadiobuttons as you wish, on the rectangle.
Finally, the code to toggle the popup visibility (but see notes in Help):
Popup1.IsOpen := not Popup1.IsOpen;
Please note! There are many properties that jointly affect the placement of the TPopup: Placement, PlacementRectangle, PlacementTarget. As I don't know your needs, I leave it to you to decide what to use.
A sample test case:
Here PlacementTarget is Button1 and Placement is Bottom.

How is the line under the text of an EditText created?

By default android.widget.EditText has a line under its text. How exactly is that technically done? I checked the source code of the EditText class, but couldn't find where this is done?
I think to know that the line is technically a background, but where is this background set? And especially, as it's just a background, how does Android ensure that this line is drawn below the text and not behind it? Answers with proofs / links to source highly appreciated.
yes, this underline is a background, which is probably ColorStateList (e.g. it changes color when pressed), but if you run your code on Android 4.x or older (pre Material Design) then this background is fixed bitmap/drawable
EditText have an android:background attribute, but it is also present for all other Views. so it is set inside source code of View, not extending EditText. and pointer to the proper drawable of background is set by styling/theming (in HERE you have some example)
EditText is using TextPaint (getPaint method) which may be used to add some extra spacing between/over/under/next to letters to ensure not-overlaying. also drawable may have padding attribute - may draw line in last row of pixels but set bottom padding to 1px and that ensures that content of this View (in this case EditText) will not be drawn under/over padding (but drawable does) - sooner View will expand a bit if have wrap_content for height
sorry for not-so-precise answer, topic needs more inwestigation and searching in sources, but maybe my points will help you find answers by yourself

Customize textview in android

I want to customize my textview as per my requirement. I have to add padding or margin dynamically when text is too long and it should look like my screenshot which I have attached here. Can anyone help me how can I implement it and below is my screenshot.
Try using this. It is customizable.
I used it so that I can have different color texts inside my "textview" , and also I used it, cause I did on it a code to resize the text size, so that it fits in the screen height. But if that was possible, I'm pretty sure what you want to do is also possible.
https://github.com/DavidPizarro/AutoLabelUI

Clickable Hidden Button or Image

In android is there anything thing like we can create a hidden button or image and it is still clickable.or alternately is there any way to achieve this functionality in Android.
In ios we have the benefit of placing a clickable hidden button.
Everything can be achieved in Android
<Button...
android:background="#null">
You can make the button transparent or translucent by using the background property:
android:background="#ARGB"
where A is the transparency, which can be set between 0-F i.e., 0 means transparent and F means opaque.
The remaining colours are R-Red, G-Green, B-Blue.
so an eg. might be:
android:background="#200B"
which gives a tinge of blue colour.
This way you can provide transparency as well as a tinge of transparent colour to your view.
This works with any view.
Also you can apply this through code:
button.setBackgroundColour(0x220000BB);
Probably use a transparent Image to the button.

Reduce text padding inside a Button

Is ist possible to reduce the text padding inside a normal Android Button a bit, in order to reduce the buttonĀ“s width?
Of course the whole text should be still visible.
There're android:minHeight and android:minWidth attribute already set on a button. Make them 0dp or 1dp to make the background fit to the text.
The "normal" Android button varies between themes, but you probably want to define a custom style for the button that inherits from your button of choice.

Categories

Resources