Is there a way to scale a button to it's text or align the text left?
I have created a static method that allows me to set a generic theme for my buttons. I know you can use LayoutOptions.Start to make the button go to the left of the page.
public static void DefaultButtonTheme(Button button)
{
//previous code
.
.
button.HorizontalOptions = LayoutOptions.Start;
}
However, for text smaller than a certain amount of letters it is center of the button.
See image below.
I have investigated a bit this behaviour and I have found that this error appears on Android but not on UWP. I have also tried to use MinimumWidthRequest="0" without result.
So as Anto Maniscalco said you should create a custom control and then overwrite the Android render using android:minHeight="0dp" as you can see in the following link. It seems that Google decided by default to a minimum size for this control.
I hope this can help you.
Related
I want to make a screenshot basically "OnRender" because I'm making the screenshot via a button that I want to disappear before the screenshot is taken and reappear afterwards.
Here's the code for the screenshot: https://hastebin.com/ecirojupov.csharp
And this is the function the button calls:
public void screenshot()
{
screenshotButton.SetActive(false);
Screenshot.TakeScreenshot_Static(Screen.width, Screen.height);
screenshotButton.SetActive(true);
}
But using either OnPre or OnPost Render doesn't work. While using OnRender leads to Unity telling me that "No cameras rendering". (In "telling" I mean text appearing in the middle of my screen) Once that message appears I can also not interact with anything anymore.
How can I take this screenshot while disabling the button?
I've created a custom button control. Basically one button-rectangle, but with two areas inside the rectangle that have a different behavior. For that reason I want to draw the hot and pressed state ONLY for the specific areas, not the hole button.
My current approach is drawing the basic-button using ButtonRenderer.DrawButton(...) with an emtpy text, draw the hot or pressed state if required and finally drawing the text. So far so good, but how do I get the (gradient) colors for the hot/pressed state?
I've tried SystemColors, KnownColors and VisualStyleRenderer.GetColor(ColorProperty.XYZ) but none of them seems to match? How can I read those colors from the host system?
EDIT:
Sample picture below:
I want the colors of both the hot and the pressed button-state - (light) blue in case of this win7 screenshot. If you zoom in you can see that a slight color gradient in both the upper and the lower half is used.
The last button shows what I want to accomplish.
Sure, I could extract the colors from the screenshots and hardcode them or use images like suggested, but that would work only for this specific system, wouldn't it?
Thanks for your answers, Jimi.
According to the accepted answer of your linked SO-question I checked ButtonBaseAdapter and ButtonStandardAdapter. As you also mentioned, ButtonRenderer.DrawButton calls VisualStyleRenderer.DrawBackground which calls the native API UxTheme.DrawThemedBackground to draw the button - the color determination happens inside.
This native API call also draws the button-border and thats the reason why I can't use it.
But I was able to solve my Problem, an unusual way, but it works.
I render both relevant states (hot and pressed) to a bitmap and extract the colors using .GetPixel. In OnPaint I create LinearGradientBrush-instances from the extracted colors and draw the hot/pressed effect over the specific areas of the normal button.
It's not the exact same behavior like a normal button (for both states the border color also changes), but I think it would look really strange if I change the border color only for a part of the button (where the hot/pressed effect is displayed) to match the normal button behavior...
If no other answers or solutions come up I'll mark this post in a few days as an answer...
Am using Devexpress Winforms 12.2 version. I designed XtraReport with Logo on right side. When image is small automatically it align to left. I need to set pull right. Their is no option to set alignment in property. How to write programmatically code in BeforePrint event of xrPictureBox ?
I tried this one but didn't work xrPictureBox1.Image = ContentAlignment.MiddleRight; showing error cannot implicitly convert type ContentAlignment to Drawing.Image
Thanks in Advance.
You'd better search their support channel, there are several threads on this subject, like XTraReport - XRPictureBox alignment and XRPictureBox - Provide the capability to specify image alignment. From the last one looks like they finally provided out of the box solution XRPictureBox.ImageAlignment Property, but you need to upgrade to v15.1. If you can't, check if some of the suggested workarounds in the links work for you.
As seen by the screen shots below. I am using a UIBarButton item to use a search icon as an image:
The image below shows that I am using a toolbar to use the image button.
This is how the bar button item is identified as a search icon.
The problem: How do I do the same thing for a UIButton?
I've tried doing this programmatically or through the interface builder but cannot find anyway to do do the same thing. I know I can use a background image for the UIButton, but I want to simply choose the identifier like a UIBarButton. Is there any way to do this?
No, UIButton has a very limited list of default icons, unlike the UIBarButtonItem. The search icon is not one of them. These are available as enum values of UIButtonType:
UIButtonTypeDetailDisclosure
UIButtonTypeInfoLight
UIButtonTypeInfoDark
UIButtonTypeContactAdd
I am coding a galery in jquery.
I have an image zoom tool that is put on a main image on an image_preload event.
I have smaller images that when clicked swaps the main image out with the one that is clicked. The new image is now the main image.
The problem is that the zoom tool is still picking up the old image even though in firebug it says that the new image was loaded into the zoomer.
I want to remove the code that i have on the main image when the switch is made and then put it back on. I'm thinking this will update the zoomer.
i have
$('.MYCLASS').jqzoom();
so can i do something like
$('.MYCLASS').jqzoom().Remove();
Thanks any help is appreciated
You would have to know what the function does in order to reverse its effects. It might be that the plugin provides a remove function, but I doubt that it would work in your instance.
One suggestion might be to simply clone the $('.MYCLASS') element and delete the original which has been bound with the jqzoom() plugin.