Is there a way to create non-filled TextInputEditText with TextInputLayout in 1.1.0+? - android-textinputlayout

I'm trying to migrate from Material components 1.0.0 to 1.1.0-alpha07 in order to be able to use ExposedDropdown style.
However, it messes up all my TextInputEditTexts as they are meant to be neither outlined nor filled.
I've tried setting TextInputEditText box backgrounds to transparent color, but that ends up making their fill completely white instead of making them see-through and exposing what's behind them (which is a brand color with gradient that spans more than the edit field, and that is why I can't just set its color to the background color as it just won't fit the gradient).
So, the question: Is there any way to keep the old-fashioned non-filled EditTexts in 1.1.0+ (while still using them inside TextInputLayout)?
Note:
I have to say that excluding a simple option to have edit fields non-filled (as they used to be) is a huge mistake since it almost completely shuts down painless migration to 1.1.0, you now basically have to force your design to change first.

Setting the TextInputEditText background to transparent worked for me.
My theme's parent is Theme.MaterialComponents.DayNight.DarkActionBar.
Another possibility is to use a ThemeOverlay for your editTextStyle:
<style name="Widget.YourTheme.TextInputLayout" parent="Widget.MaterialComponents.TextInputLayout.FilledBox>
<item name="materialThemeOverlay">#style/ThemeOverlay.YourTheme.TextInputEditText</item>
</style>
<style name="ThemeOverlay.YourTheme.TextInputEditText parent="ThemeOverlay.MaterialComponents.TextInputEditText.FilledBox">
<item name="editTextStyle">#style/Widget.YourTheme.TextInputEditText item>
</style>
<style name="Widget.YourTheme.TextInputEditText parent="Widget.MaterialComponents.TextInputEditText.FilledBox">
<item name="android:background">#android:color/transparent</item>
</style>
<com.google.android.material.textfield.TextInputLayout
style="#style/Widget.YourTheme.TextInputLayout"
...
<TextInputEditText>
...
</TextInputEditText>
</com.google.android.material.textfield.TextInputLayout>

I managed to find a rather simple answer to the problem.
The solution is to use app:boxBackgroundMode="none" with the filled box style.
You can also put an application-wide style for text input layouts (also applying the aforementioned attribute) using textInputStyle attribute in your app's theme and supplying the desired style.
As a side note, this just points out the catastrophic lack of easily-accessible documentation and guides that plagues this library.

Related

Why is the Designer in Codename one not reporting the attributes I set?

I started a Codename One project with the "Hello World bare bones". I used to define the styles in the Theme tab from the Designer but now it is becoming tedious.
Actually for some selectors, even if I override (unchecking the Derive box) some properties the style is not changed in the Designer (see below) or in the app itself.
However, in the list of selectors, the color is not the one I selected but the alignment seems to be it.
It seems that the theme is locked somewhere. Do I make a mistake, or should I set a constant to "unlock" the theme, or even should I clear some directories?
Please note that I am using NetBeans with designer V 1.1
.
Edit March 1st 2017
Following #Diamond's great tips, I was able to change the foreground color by setting the Border to empty (instead of NULL). However now the alignment is still not what I expect (see below). How can I do for this property ?
Any help appreciated,
In the Designer, Border is superior to background color and background image. Which means if the border image is set, a background color will have no effect unless the border is just a stroke or line.
Always solve this with these few steps:
Go to the Border tab and uncheck the override.
Click the ... button next to Border Help and a new Dialog will show.
Change the Type (First line) to Empty and click Ok.
Your background color will now have an effect.

How to mix text-only RibbonToggleButton and image-only RibbonButton in Ribbon for WPF?

I'm using the Microsoft Ribbon for WPF October 2010 and have got 3 buttons next to each other, inside a RibbonControlGroup. The left and the right ones are text-only RibbonToggleButton controls, the one in the middle is an image-only RibbonButton. The buttons have a defined width to match the row above.
My code:
<r:RibbonControlGroup>
<r:RibbonToggleButton Width="110" Label="Outgoing" IsChecked="True" />
<!-- Padding and Height set to align the buttons/image -->
<r:RibbonButton Width="30" Padding="5 0" Height="24" SmallImageSource="Images\Small\arrow_swap.png" />
<r:RibbonToggleButton Width="110" Label="Incoming" />
</r:RibbonControlGroup>
The problem is that as soon as I apply the SmallImageSource to the middle button, the other two get spacings for images, causing the text not to be centered anymore. That is problem (1).
Because I didn't find a quick solution, I tried to add the image of the middle button not via SmallImageSource, but by adding it as <Image> for the content of the button. However, the button would remain empty. That is problem (2).
My third solution was to add images to the left and the right button, too. Unfortunately there is nearly no margin between the image and text, which looks quite ugly. I tried several things to enlarge the margin like adding a <Style TargetType="Image"> to the <RibbonToggleButton.Resources>, but although the editor accepts it and displays the spacing at designtime, the margin is gone again at runtime. That is problem (3).
Does anybody have an appropiate solution to any of the three problems? I cannot get it to work. The number of the problems is also the preference of the alternatives, (1) being the most favourite to use with an appropiate hack.
It seems you cannot do that. Its by design.
As per MSDN (here about half way down the page):
Related ribbon controls can be grouped together in a RibbonControlGroup. When a control group is resized, one RibbonControlSizeDefinition is applied to all of the controls in the RibbonControlGroup. The RibbonControlGroup is positioned in the RibbonGroup as if it were one control.
All the controls in a RibbonControlGroup shares the same RibbonControlSizeDefinition. Hence, in your case image will be added for all the buttons.
You may use RibbonGroup instead if you do not want to glue all your controls very closely. This way you can customize each button container by using different RibbonControlSizeDefinitions.

FlowDocument loses ClearType in child elements when placed in window with custom glass

So the new WPF 4 text rendering looks great, but enabling the aero glass effect on a window requires that you change the background to transparent, which of course disables ClearType rendering.
Using the provided RenderOptions.ClearTypeHint=Enabled allows you to designate child elements to reenable ClearType rendering from that point in the tree. I've found a few other topics that talk about doing this for the ScrollViewer used internally inside RichTextBox and FlowDocumentScrollViewer, and creating a custom style does indeed fix it so that my FlowDocument gets ClearType rendering again.
However, this only applies to top level paragraphs in the FlowDocument. If I add floaters or figures, or a table, any text inside them is inexplicably grayscale again. I know that the glass effect is to blame, since disabling it reenables the ClearType rendering.
I looked through the visual tree with Snoop, but both the main content (which renders properly) and the sub-content (which is grayscale) have similar element hierarchies without anything to which I can attach RenderOptions.ClearTypeHint.
Has anyone run into this problem? Is there a workaround or a solution? I checked Connect but there isn't any bug filed about this. It's quite an annoying problem.
After doing a lot more research, and comparing the way different controls work on and off of aero glass, I've found a few answers. The TextBox control doesn't work properly either, but portions of FlowDocument and things like TextBlock do, which prompted me to explore why.
After digging around in reflector for a while, I found that when using the advanced text formatting APIs to get text and render it onto a drawing context, the RenderOption flags essentially go ignored, since the drawing system knows from the root visual (the window) that transparency was enabled. Once that happens, all the RenderOptions flags in the world aren't going to get ClearType back.
I did happen to stumble on a work-around though. If you have access to the DrawingContext and are doing the low-level text rendering yourself, you can do a DrawRectangle behind the text with a fill, and ClearType gets reenabled. I assume that this is the only way for the renderer to be sure that it has a proper background to draw on.
So in summary, you need to do your own text drawing, and additionally you need to explicitly draw a background using the same DrawingContext behind your text in order for ClearType to get rendered properly.
I know this could get tedious, but have you tried setting general styles like so:
<Style TargetType="Paragraph">
<Setter Property="RenderOptions.ClearTypeHint" Value="Enabled"/>
</Style>

Setting the ToolTip in a WPF chart?

I would like to set the ToolTip on my chart line, pie, area, bubble to include both the X and the Y values.
Charting is use is defined here :
xmlns:chartingToolkit="clr-namespace:System.Windows.Controls.DataVisualization.Charting;assembly=System.Windows.Controls.DataVisualization.Toolkit"
I've learned that I can use the ControlTemplate to do this and by overriding the entire thing, I can also set the tooltip.
But this also changes things which I like, the random color selection, the status changes etc.
Is there a way to apply only the tooltip binding to all chart series types, without having to override the entire thing for each of the types (that makes for a very long and mostly irrelevant code, which mostly I don't understand and don't care about)
Thanks! (My first post)
...
You have to copy a part of the original source (the style).
Check this site: http://blogs.msdn.com/b/delay/archive/2010/04/22/nobody-likes-a-show-off-today-s-datavisualizationdemos-release-includes-new-demos-showing-off-stacked-series-behavior.aspx
Here you can download this zip file that contains an example project in WPF.
Read the source/style in ChartStyling.xaml and your question will most likely be answered!

Is it possible to add more than one effect to a Label in Blend?

I'd like to have a label with a blur effect and a drop shadow effect.
If you use the older BitmapEffect, then you can make use of the BitmapEffectGroup:
<Label Content="Hello">
<Label.BitmapEffect>
<BitmapEffectGroup>
<DropShadowBitmapEffect />
<BlurBitmapEffect />
</BitmapEffectGroup>
</Label.BitmapEffect>
</Label>
BitmapEffect, however is being depreciated, and UIElement.Effect is the preferred method to add effects. To combine multiple behaviors into a Effect of this type, you will have to create a custom effect that does what you desire. As shown here, which will require more then just editing the elements through blend.
Also, take a look here: WPF Pixel Shader Effect Library
They have some exelent examples and pre-built effects as well as good tutorial on how to create your own.
It's a bit of a hack, but you could just wrap the label in a grid or border and apply the blur effect to that while applying the dropshadow to the label directly.

Resources