Adding Android views together - xamarin.android

Under iOS, I can have something like this
var myButton = new UIButton(new RectangleF(4,4,100,42));
var myTextView = new UITextView
{
Text = "Hello",
Frame = new RectangleF(4,4,42,21)
};
myButton.Add(myTextView);
this allows me to add a UITextView to a UIButton. Very quick and very simple.
Is there something similar that allows me to do something similar on Android?

This is possible if the type of the view is ViewGroup, otherwise no.
You can overlay views, i.e. when they are both inside of a FrameLayout or RelativeLayout.
A short list of ViewGroup type of views I can remember are:
LinearLayout
RelativeLayout
FrameLayout
GridLayout
CardView
Other special views (limited number of nested views)
DrawerLayout
SlidingPaneLayout
List type of views
ListView
RecyclerView
Spinner
In short what you want is not possible with the two views you gave as an example. However, it is entirely possible to change the look of those views to your liking.

Related

Vaadin 23 add the common part of several Views into content part of AppLayout

I have MainLayout defined (extended from AppLayout), where I have configured Header and Drawer. Also, I have 3 different views which use MainLayout via #Route annotation.
There is some similarity between such 3 views - they have the common tabs at the top of the content area. Is it possible somehow to add such tabs into MainLayout content area? Or inside of AppLayout I may only add something to Header and Drawer only? How to properly implement such common tabs for these 3 views ? Right now I added duplicates of these tabs into each of the view and they don't work as expected(incorrect highlighting of selected tab). How to make them common for 3 views ?
I created one more layout class with #ParentLayout(MainLayout.class) annotation and derived from VerticalLayout implements RouterLayout. Inside this layout I added my tabs. Now, for each of the mentioned in the question views, I use this new Layout.

SegmentedControl and Uipageview query

How can i add sub options with segmented control like in the given Screen?
Also i want to inquire about how can i add blurr effect to last/next page views just like the given screen. Thanks for your help

Unable to set GridLayout height programatically

I am trying to implement swipe actions on ListView for each element. Whole view is AbsoluteLayout, with two GridLayouts: one acting as "foreground"(list element) and other as "background" (swipe actions). I want them both to have equal height of "foreground" (which is dynamic and differs for every list element).
I succesfully implemented this on Android - I call a method on layoutChanged event
onLayoutChanged(args: EventData) {
const foregroundNotificationTemplate = (<AbsoluteLayout>(args.object)).getChildAt(1);
const backgroundButtons = (<AbsoluteLayout>args.object).getChildAt(0);
backgroundButtons.height = foregroundNotificationTemplate.getActualSize().height;
}
This unfortunatelly is not working on iOS. I tried to access Frame and UiView, but with no success - it has height of background content.
Demo presenting the problem on Nativescript Playground:
https://play.nativescript.org/?template=play-ng&id=4LRwDC
You don't necessarily have to use AbsoluteLayout as you are animating the position with translate which is possible with any layout. So using GridLayout instead of AbsoluteLayout should solve your problem on both platforms and you may also get rid layoutChanged event for measuring height.
Also note that your ListView item template can not be dynamic, you should not use ngIf or anything that would alter the structure of the list item, use multiple templates instead.
For anyone looking for working solution, thats what Manoj proposed: https://play.nativescript.org/?template=play-ng&id=yXggcv

How to make text field like this in swift?

I want to make this kind of text field in my application. Could you guys suggest how to create a text field like the ones shown in this picture?
What you're showing in the picture is table view cells, not simply text fields. Do you want table view cells that look like that? You want table view cells if your view controller is a UITableViewController. You can easily create a nib file (cmd-n, iOS User Interface, Empty, name and save it), drag out a Table view cell from the asset library, and then drag in the label and text field (see below) into the cell.
If you don't have a UITableViewController, you could just put a UILabel (for the 'Apple ID' or 'Required' part) in your view controller's view in interface builder and then add a regular text field, write its placeholder in the Attributes Inspector, and then choose the 'Border Style' (again, in the right Utilities panel in Xcode) on the far left, the one that looks like dashed lines (this is 'no border')
Use UITextBorderStyleLine from UITextBorderStyle enum
ObjC
typedef enum {
UITextBorderStyleNone,
UITextBorderStyleLine,
UITextBorderStyleBezel,
UITextBorderStyleRoundedRect
} UITextBorderStyle;
Swift
enum UITextBorderStyle : Int {
case None
case Line
case Bezel
case RoundedRect
}
Edit:
The first image was different from the new one. So, the picture shows that It's a table view(as you can see there's header for each section) that the first section contains two text fields. The two text fields' border style is UITextBorderStyleNone.
Use Eureka! It's an open source library available on Github - https://github.com/EurekaCommunity
It's really useful for creating form-based table views like the one you've described above.

What UI element might this be? (Custom tab-bar?)

http://www.flickr.com/photos/fraserspeirs/4329430635/in/set-72157623224262135/
The above is a link basically showing the form fill view of the numbers app on the iPad. Any idea as to how to achieve such a functionality which sort of looks like our vanilla tabs on Chrome?
You could do it with just buttons set to Custom type and using an image for the background. Then when they are clicked, bring the specific UIView to the front.
To create the tabs from a single image use UIImage's stretchableImageWithLeftCapWidth: topCapHeight:
http://tcninja.blogspot.com/2010/09/ios-adding-stretchable-uiimage-as.html
This will let you dynamically set the image's width in a way that will use the middle of it to fill the new area rather than stretching (and warping) the outer edges.
I would have implemented this with simple UIButtons. All you need to do is to style them (pngs or whatever), and track which one is the current.

Resources