I want to create a dialog with a custom layout and no title. Also, the dialog should open on the top right corner of the screen. Here is the screenshot of what I want.
In xamarin.iOS is something like PopOverViewContainer. May it's in Android the same.
Maybe by changing the gravity of the dialog using the WindowManager Attributes property:
Android.App.AlertDialog.Builder builder = new AlertDialog.Builder(Activity);
AlertDialog alertName = builder.Create();
alertName.SetTitle("Warning...");
alertName.SetIcon(Android.Resource.Drawable.IcDialogAlert);
alertName.SetMessage("This is a warning message");
alertName.SetButton("OK", (s, ev) =>
{
return;
});
alertName.Show();
var window = alertName.Window;
var wlp = window.Attributes;
wlp.Gravity = GravityFlags.Top;
wlp.Flags = WindowManagerFlags.DimBehind;
window.Attributes = wlp;
You should be able to change the gravity parameter and the flags (which currently stops the background to the dialog from dimming
I have used below code to achieve my requirement.
Window window = dialog.Window;
WindowManager.LayoutParams wlp = window.Attributes;
wlp.Gravity = GravityFlags.Top | GravityFlags.Right;
window.Attributes = wlp;
Related
How can I add clicklistener to vaadin label, without putting into horizontal or vertical layout? I want to show tool tip on clicking of the label, not on mouse over.
That's not possible.
Putting it in a layout is really not that big of a deal, the following is all you need to do:
HorizontalLayout labelLayout = new HorizontalLayout();
labelLayout.addComponent(new Label("text"));
labelLayout.addLayoutClickListener( e -> <code that does something>);
If you don't want to do that you can use a third party add on which does exactly what you want. https://vaadin.com/directory#!addon/labelbutton
With it you can do:
LabelButton label = new LabelButton("text", event -> <do something>);
I recommend you use a button and add style borderless as shown on the code below. It will appear as a label.
VerticalLayout vertical = new VerticalLayout();
vertical.addComponent(new Label("Am the Hint..."));
PopupView popup = new PopupView(null,vertical);
Button b = new Button("Show Hint");
b.addStyleName(ValoTheme.BUTTON_BORDERLESS);
b.addClickListener((Button.ClickEvent event) -> {
popup.setPopupVisible(true);
});
addComponents(b, popup);
I'm writing a Forms app. How to position a view right at the bottom of the screen and when some entry is focused and the keyboard is visible, the view to be right above the keyboard? On android, it is possible to set Window.SetSoftInputMode(SoftInput.AdjustResize) and that will make the Content resize every time the keyboard is appearing/disappearing. However, I need the status bar to be transparent and SoftInput.AdjustResize doesn't work with WindowManagerFlags.TranslucentStatus. My question is, how do I position a view right above the keyboard without setting SoftInput.AdjustResize?
Take this example:
public Page1()
{
InitializeComponent();
var al = new StackLayout
{
HorizontalOptions = LayoutOptions.FillAndExpand,
VerticalOptions = LayoutOptions.FillAndExpand
};
var button = new BoxView {Color = Color.Red, VerticalOptions = LayoutOptions.EndAndExpand};
var entry = new Entry {HorizontalOptions = LayoutOptions.Fill};
al.Children.Add(entry);
al.Children.Add(button);
Content = al;
Content.SizeChanged += (sender, args) =>
{
button.Layout(new Rectangle(0, Content.Height - 120, App.Dimensions.Width, 120));
};
}
If you run this code, when you'll press the input, nothing will change, the "button" will remain on the bottom of the screen not visible because of the overlaying keyboard.
If we add Window.SetSoftInputMode(SoftInput.AdjustResize) in MainActivity's onCreate it works fine, the box is moved above the keyboard on entry's focus.
Also, if we change Content = al; to Content = new ScrollView {Content = al};, it works fine.
However, if we add Window.AddFlags(WindowManagerFlags.TranslucentStatus); in MainActivity's onCreate, none of those methods work anymore.
Thanks in advance.
I'm writing a Forms app. How to position a view right at the bottom of
the screen and when some entry is focused and the keyboard is visible,
the view to be right above the keyboard?
If you are using Xamarin Forms, then wrapping your UI elements in a ScrollView should do the trick. Something like this if you are using XAML:
<ScrollView>
<ScrollView.Content>
// Your Original XAML content here
</ScrollView.Content>
<ScrollView
EDIT:
Looking at the example you just added, I THINK I know what is happening. So, the ScrollView Trick only works for elements that require keyboard input. I.e if you instead had an entry element at the bottom of the screen, and wrapped everything in a ScrollView like I suggested, then the keyboard should push the entry element up for you. However in your case you have a boxview at the bottom of the screen, which the keyboard simply runs over.
What you have for Content.SizedChanged is a good idea, however I don't think the size of the view actually changes when the keyboard pops up (at least, Content.SizeChanged isn't called when the keyboard pops up), so that part of your code is really only called on loading of the page from the MCVE you provided.
HOWEVER, I was able to move the 'button' up when the keyboard appears by doing this:
Replace
Content.SizeChanged += (sender, args) =>
{
button.Layout(new Rectangle(0, Content.Height - 120, App.Dimensions.Width, 120));
};
With
entry.Focused += (sender, e) =>
{
button.TranslationY -= 120;
};
You may have a heck of a time getting that magic translation number for all the different devices and orientations though. When I tested it on the iPhone 6 simulator I had to push way above 120 before I could see it above the keyboard.
Hope that helps!
I am developing one application and i have added one button (CButton) which is calling SHBrowseForFolder() function. But the problem is that the button is still active and also it is letting me to click my parent window. Also i can click again and again that button and multiple browsing window are coming.
What i want to know that is there any way to use SHBrowseForFolder() in a DoModal() way, so that the control did not return to the parent window till user click that Ok/Cancel button of the folder browse window? I do not want to disable that button after clicking once or something like that.
I am using Visual Studio 2010.
Thanks in advance.
Sure it's possible:
void CUtility::BrowseFolder(CWnd* pParentWnd, const CString& sTitle, CEdit& Edit)
{
LPMALLOC pMalloc = NULL;
::SHGetMalloc(&pMalloc);
TCHAR pBuffer[MAX_PATH] = {0};
LPITEMIDLIST pidlRoot = NULL;
BROWSEINFO bi;
bi.hwndOwner = pParentWnd->m_hWnd;
bi.pidlRoot = NULL;
bi.pszDisplayName = pBuffer;
bi.lpszTitle = sTitle;
bi.ulFlags = BIF_USENEWUI;
bi.lpfn = NULL;
if((pidlRoot = ::SHBrowseForFolder(&bi)) == NULL)
return;
if(::SHGetPathFromIDList(pidlRoot, pBuffer))
Edit.SetWindowText(pBuffer);
if(pidlRoot)
pMalloc->Free(pidlRoot);
}
In WP7 silverlight app, i wanted to use a storyboard animation on a particular event.
The animation is changing button height property from x to y points (changed for query).
I am using below code in my program
Storyboard myStoryBoard = new Storyboard();
myStoryBoard.Duration = new Duration(TimeSpan.FromMilliseconds(200));
DoubleAnimation myDoubleAnimation = new DoubleAnimation();
Storyboard.SetTargetName(myDoubleAnimation, button1.Name); // button1 is normal button on UI
Storyboard.SetTargetProperty(myDoubleAnimation, new PropertyPath(Button.HeightProperty));
myDoubleAnimation.From = 200;
myDoubleAnimation.To = 300;
myStoryBoard.Children.Add(myDoubleAnimation);
myStoryBoard.Begin();
when i run my code, i am hitting with
Cannot resolve TargetName button1 error
any easy fix for my issue?
I think you can use SetTargetName only if the Storyboard is in the visual tree. I suggest using SetTarget instead: http://msdn.microsoft.com/en-us/library/system.windows.media.animation.storyboard.settarget%28v=vs.95%29.aspx
Storyboard.SetTarget(myDoubleAnimation, button1);
hi i have created a user control.
now i want to add this control to a page e.g. when the user clicks a button (important is, that i dont want to add it direcly in xaml, i want to add id in the c# code section)
how to so this?
In your button's Click event, you could do something like:
MyControl control = new MyControl();
// Set whatever properties you need in your control here
LayoutRoot.Children.Add(control);
if (listBox1.Items.Count == 0)
{
Popup popup = new Popup();
WPCpopup po = new WPCpopup(popup);
popup.Width = System.Windows.Application.Current.Host.Content.ActualWidth;
popup.Child = po;
popup.VerticalOffset = 300;
popup.IsOpen = true;
}
WPCpopup is usercontrol