How to set seekbar unmovable using kotlin? - android-studio

How to set seekbar widget unmovable using kotlin language in android studio?

//kotlin
mySeekBar.enabled = false;
//java
mySeekBar.setEnabled(false);
This will block it from moving and it will be frozen

Related

Set font custom searchview Android studio

Select the custom font for search view:
searchView = (SimpleSearchView) findViewById(R.id.searchView);
searchView.getSearchEditText().setTypeface(AppFontClass.getCurrentTypeFace(getApplicationContext()));
TextView searchText = (TextView) searchView.findViewById(android.support.v7.appcompat.R.id.search_src_text);
Typeface myCustomFont = Typeface.createFromAsset(getAssets(),"fonts/myFont.ttf");
searchText.setTypeface(myCustomFont);

navigation background image xamarin ios

I'm new in xamarin(start using 2 week), now I need do a background Image wtih navigation bar like below picture? how can I do it?
You need to add an UIImage in your UIViewController (filling whole or only top of ViewController) setting your UINavigationBar to a clear color with
YourNavigationBar.SetBackgroundImage(new UIImage(), UIBarMetrics.Default);
YourNavigationBar.ShadowImage = new UIImage();
YourNavigationBar.Translucent = true;
YourNavigationBar.BackgroundColor = UIColor.Clear;
To reset UINavigationBar transparency you have to use:
YourNavigationBar.SetBackgroundImage(null, UIBarMetrics.Default);

How to hide shortcut bar in iOS9 UIWebview?

I would like to hide bar which is on top of keyboard (undo, redo, copy and back, forward buttons) when user clicks on textfield in UIWebView.
Does anybody know how to do it?
Thanks!
Using method swiziling we can remove the keyboard shortcut bar (only works with ObjC).
- (void)hideKeyboardShortcutBar
{
Class webBrowserClass = NSClassFromString(#"UIWebBrowserView");
Method method = class_getInstanceMethod(webBrowserClass, #selector(inputAccessoryView));
IMP newImp = imp_implementationWithBlock(^(id _s) {
if ([self.webView respondsToSelector:#selector(inputAssistantItem)]) {
UITextInputAssistantItem *inputAssistantItem = [self.webView inputAssistantItem];
inputAssistantItem.leadingBarButtonGroups = #[];
inputAssistantItem.trailingBarButtonGroups = #[];
}
return nil;
});
method_setImplementation(method, newImp);
}
inputAccessoryView
: This property is typically used to attach an accessory view to the
system-supplied keyboard that is presented for UITextField and
UITextView objects.
So the new implementation block will be fired every time the keyboard pops up.
I posted this answer in Hide shortcut keyboard bar for UIWebView in iOS 9 as well
I am able to hide those using these lines
let item:UITextInputAssistantItem = self.textFieldName.inputAssistantItem
item.leadingBarButtonGroups = []
item.trailingBarButtonGroups = []
Hope this will help.

UITextView undo manager do not work with replacement attributed string (iOS 6)

iOS 6 has been updated to use UITextView for rich text editing (a UITextView now earns an attributedText property —which is stupidly non mutable—). Here is a question asked on iOS 6 Apple forum under NDA, that can be made public since iOS 6 is now public...
In a UITextView, I can undo any font change but cannot undo a replacement in a copy of the view's attributed string. When using this code...
- (void) replace: (NSAttributedString*) old with: (NSAttributedString*) new
{
1. [[myView.undoManager prepareWithInvocationTarget:self] replace:new with:old];
2. old=new;
}
... undoing is working well.
But if I add a line to get the result visible in my view, the undoManager do not fire the "replace:with:" method as it should...
- (void) replace: (NSAttributedString*) old with: (NSAttributedString*) new
{
1. [[myView.undoManager prepareWithInvocationTarget:self] replace:new with:old];
2. old=new;
3. myView.attributedText=[[NSAttributedString alloc] initWithAttributedString:old];
}
Any idea? I have the same problem with any of the replacement methods, using a range or not, for MutableAttributedString I tried to use on line "2"...
Umm, wow I really didn't expect this to work! I couldn't find a solution so I just started trying anything and everything...
- (void)applyAttributesToSelection:(NSDictionary*)attributes {
UITextView *textView = self.contentCell.textView;
NSRange selectedRange = textView.selectedRange;
UITextRange *selectedTextRange = textView.selectedTextRange;
NSAttributedString *selectedText = [textView.textStorage attributedSubstringFromRange:selectedRange];
[textView.undoManager beginUndoGrouping];
[textView replaceRange:selectedTextRange withText:selectedText.string];
[textView.textStorage addAttributes:attributes range:selectedRange];
[textView.undoManager endUndoGrouping];
[textView setTypingAttributes:attributes];
}
Mac Catalyst (iOS14)
UITextView has undoManager that will manage undo and redo for free without any additional code.
But replacing its attributedText will reset the undoManager (Updating text and its attributes in textStorage not work for me too). I found that undo and redo will works normally when formatting text without replacing attributedText but by standard edit actions (Right click on highlighting text > Font > Bold (Mac Catalyst)).
So to fix this :
You need to set the allowsEditingTextAttributes of UITextView to be true, this will make UITextView support undo and redo of attributedText.
self.textView.allowsEditingTextAttributes = true
If you want to change the text of attributedText, use replace(_:withText:) of UITextInput, or insertText(_:) and deleteBackward() of UIKeyInput that UITextView conforming to.
self.textView.replace(self.textView.selectedTextRange!, withText: "test")
If you want to change attributes of text, use updateTextAttributes(conversionHandler:) of UITextView instead.
self.textView.updateTextAttributes { _ in
let font = UIFont.boldSystemFont(ofSize: 17)
let attributes: [NSAttributedString.Key: Any] = [
.font: font,
]
return attributes
}
For changing text and its attributes in specific range, modify the selectedRange of UITextView.
To implement undo and redo buttons, check this answer : https://stackoverflow.com/a/50530040/8637708
I have tested with Mac Catalyst, it should work on iOS and iPadOS too.
The Undo Manager is reset after setting its 'text' or 'attributedText' property, this is why it does not work. Whether this behavior is a bug or by design I don't know.
However, you can use the UITextInput protocol method instead.
(void)replaceRange:(UITextRange *)range withText:(NSString *)text
This works.

Setting the navigation bar color in monotouch

I am attempting to write an application with MonoTouch. I need to set the background color of the navigation bar. I'd like to set it to orange. This seems like an easy task, but I can't seem to get it to work. Currently, I'm doing the following in the AppDelegate.cs file:
this.window = new UIWindow (UIScreen.MainScreen.Bounds);
this.rootNavigationController = new UINavigationController();
UIColor backgroundColor = new UIColor(74, 151, 223, 255);
this.rootNavigationController.NavigationBar.BackgroundColor = UIColor.Orange;
However, the navigation bar color is still the default color. How do I set the background color of the navigation bar?
You can do this on an ad-hoc basis as Rob described using the TintColor property:
this.rootNavigationController.NavigationBar.TintColor = UIColor.Orange;
Alternatively, you can also set the TintColor for all UINavigationBars at once using the UIAppearance proxy in iOS 5. This is usually done somewhere near DidFinishLaunchingWithOptions method in the AppDelegate:
UINavigationBar.Appearance.TintColor = UIColor.Orange;
You can check out the Apple doc for more detailed information and implementation restrictions:
http://developer.apple.com/library/ios/#documentation/uikit/reference/UIAppearance_Protocol/Reference/Reference.html
Try changing the TintColor and Translucent properties.

Resources