I have installed Aritchie userdialogs version 5 and I'm using Xamarin.Forms Version 2.2. When I use UserDialogs.Instance.ErrorToast on Android, if the text is longer than screen width, it cut.
This is a problem cause the user might not see important part of a message.
(Same toast message on iOS for example not truncated and it takes the size of the content automatically).
How can I increase the height of this rectangle, or set an autosize if exist ?
When your Android app is running with a AppCompatActivity based Activity (which it seems that your is since it is using Material Design), Acr UserDialogs is creating a SnackBar for displaying the Toast, and by design a Google/Android SnackBar is supposed to be a short message.
https://www.google.com/design/spec/components/snackbars-toasts.html
Snackbars provide lightweight feedback about an operation by showing a brief message at the bottom of the screen
As such there is not built-in method for auto-sizing or multi-line wrapping of text. There are other SO questions related to this and their answers all point to the thing, you would need to modify the Android-based view that is contained within the Snackbar fragment when it is created:
TextView tv = (TextView) view.FindViewById(Resource.Id.SnackbarText);
// change the font size, view size, content wrap settings, etc...
If these are important messages that the user needs to dismiss, perhaps using a popup dialog would work in your design.
Related
I have an app which allows users to send messages to each. The process is accomplished by saving the sent messages in a local SQLite database, while actually sending the messages to a database and using push notifications to send the message to the recipient's SQLite database. The set up I have works fine. However, what I am confused about is how to set up the actual interactive UI for the user (I am using XCode). I figured it should be a UITableView with each table cell representing a message. However, with this approach I run into a few requirements:
Variable TextView Sizes
Just as with regular iOS messaging, the TextView's size needs to be variable, adjusting its dimensions to fit all of the text in each message. I do not know how to accomplish this. I have a general understanding of how to generally vary sizes, but no clue how to dynamically have it based on the text within that view.
Variable TextView Positions
Again, just as with regular iOS messaging, the textview needs to be offset to either the right or left side depending on whether the sender was the user or who the are conversing with, respectively. I also do not know how to do this, because it changes the center of the textview.
Non-selectability
Xcode allows cells to be pressed. Handling what happens after this selection can be achieved by the didSelectRowatIndexPath tableView function. I can simply not implement this, but clicking on the cell causes it to turn darker to indicate it has been pressed. I would like to eliminate this while retaining the ability to, say, select some of the text and copy and paste it or whatever (just like messaging works normally on your phone).
Other Approaches?
This is the real meat of the question. I have considered the above approach because that is all that I have been able to come up with based on my limited experience with XCode UI elements. If there is a better approach (perhaps even a pod or framework) for this purpose I would love to hear it. I do not need the messaging UI to look amazing, just clean and crisp.
I suggest the following:
Variable TextView Sizes:
I assume you do use auto layout. If you don’t yet, please consider using it since it make life much easier!
If you use a UITableView, you can adjust the height of its UITableViewCells dynamically, depending on the actual content by using self-sizing cells. You can find a tutorial how to do this here.
Variable TextView Positions:
I assume you have a UITextView within a table view cell. In this case, you have to set auto layout constraints to the borders of the cell’s contentView. If you define a custom subclass of a UITableViewCell, you can define in this class 2 IBOutlet properties that are linked to say the left and the right layout constraints (e.g. var leftLayoutConstraint: NSLayoutConstraint). Then, you can set the constraint’s constant property as required when the cell is laid out, i.e. in the layoutSubviews function of the custom table view cell.
Non-selectability:
I am not sure what you mean by „I can simply not implement this“. Please make sure that you set the delegate property of the UITableView to the view controller where you want to handle cell selection. Selecting a cell changes the cells color by default, but you can change this: In the storyboard, select your table view’s prototype cell, and open Xcode’s utility pane (top rightmost button). Under „Table view cell“ you find „Selection“ that you can set to „None“.
I hope this helps!
When my app is resumed after taking a picture, the layout of the view is displaced:
This effect only occurs when an input node, e.g. TextField was focused and the layout had to be adjusted in order to not make the keyboard cover the input node. Even more interessting, I couldn't reproduce the issue while selecting a picture.
The error occurred when I updated Android 6.0 to 7.0
Edit:
Every now and then, there is a similar error, when the keyboard is hidden (see link):
I have a ContentView with a StackLayout with multiple children sized to the full width of the screen. In other words, if the screen width is 320 and I have five children, the inner StackLayout is resized to 1600.
In this ContentView, I have Next and Previous buttons that when clicked, animate the inner StackLayout's TranslateX property. Basically, I'm creating a carousel by translating the StackLayout within the ContentView. I chose this route because I was having layout issues using a ScrollView and a custom renderer when I would modify that layout of the view (by hiding labels, etc.)
However, I've hit a snag. Content that appears after I set the TranslateX property doesn't receive any tap events. I believe I might have to reset some tappable area, but I'm not even sure where to begin with that. Does anyone have any suggestions?
I posted this same question in Xamarin's Forums, and someone there answered. For anyone looking, the answer is here: https://forums.xamarin.com/discussion/comment/142914/#Comment_142914
If that link stops working at some point in the future for some reason, the relevant answer is:
Hit testing is done based on the actual frame of the control determined by layout, but translation happens after layout. Therefore hit testing does not take translation into account. If you want a view to be touchable then you should update its layout directly rather than using translation.
We have an SMS app for Android Wear (https://play.google.com/store/apps/details?id=com.awear.coffee)
Right now we use regular notification actions and when you select Reply it launches our activity on the watch. I want to replace the Reply action with a notification page with a custom activity that holds a few buttons and a list of strings.
I've tried two approaches.
Create a large notification page that holds the content
This doesn't work because Notification.WearableExtender.setCustomContentHeight has a hidden max value so the content gets clipped. I think it's the same height as if you use setCustomSizePreset(SIZE_LARGE). I've verified that if I use a default notification with a ton of text it can be larger than this, but if you use a custom display intent it gets clipped.
Use a fullscreen notification page and add a scrollview to it
This doesn't work because the input gets blocked somehow. Whenever you scroll the activity receives Action.DOWN, Action.MOVE, Action.CANCEL in that order, so you only get one Action.MOVE no matter how long you drag. I'm guessing this is because the OS wants to control the left/right swipes.
Any ideas on how to get around this? I've tried setting custom onTouch listeners but they still never receive all the touch events.
Any help would be appreciated. It would make our app much better if we could reduce the number of taps and swipes needed.
Jakob
if you are using bridged notification(With out having wear module) You can insert extended text content to your notification by adding one of the "big view" styles(InboxStyle,BigTextStyle) to your notification. On a handheld device, users can see the big view content by expanding the notification. On a wearable device, the big view content is visible by default.
BigTextStyle bigStyle = new NotificationCompat.BigTextStyle();
bigStyle.bigText(someBigText);
NotificationCompat.Builder notificationBuilder =
new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_small)
.setContentTitle(title)
.setContentText(contentText)
.setContentIntent(viewPendingIntent)
.addAction(R.drawable.ic_map,
getString(R.string.somestring), mapPendingIntent)
.setStyle(bigStyle);
I ran into the same problems.
The limit on setCustomContentHeight is frustrating. I couldn't find a way around it.
Likewise, there doesn't seem to be a good way to circumvent the limitations imposed on tap-listeners with the fullscreen notification.
My solution was to add an Action to the first page of the notification that launches an Activity based on the GridViewPager. Once there, the limitations are gone, but it still mostly looks like a Notification. With the principal differences being, (1) you have to 'tap' the first Notification card, rather than swipe it, and (2) swiping up and down don't automatically go to the next/previous notifications.
When editing code, Xcode is capabale of displaying in-text controls, like drop down buttons which can show context menu's. I've seen other OS X apps that handle text capable of similar features. See the attached sample.
I presume this effect is obtained using NSTextAttachmentCell - although I'm not sure whether this is the proper way to implement this.
For my own app I would like to use this technique as well.
I have the following questions:
Is NSTextAttachmentCell the correct way to implement such a feature? If not, what would be?
How do I attach a control -comparable to the one in the above sample- to a specific range of text so that its location within NSTextView is dynamic and follows layout actions?
I found this which gives some hints but does not cover the attachment to specific text ranges.
Although NSTextAttachmentCell will work, it has a disadvantage: the cell will become just a glyph in the text which was not what I wanted. It distorts the layout of the text, is selectable etc. I wanted the cell to be drawn over the text, just like the behaviour in Xcode.
The challenge was to find a way of translating a point from a Mouse Moved event to the position of a particular string of characters inside the NSTextView.
After some more digging I found a little gem in Apple's demo apps called LayoutManagerDemo. This demo shows a custom subclass of NSTextView capable of highlighting individual characters, words and lines while the mouse is hoovering its view. From there on it was pretty easy to fade in a button at the required NSPoint and then show a popup menu with some options.