how to create a carousel in a fragment - kotlin

I'm trying to assemble a carousel inside a fragment, but I can't find a tutorial or anything like that.
Now I just need the Fragment, could someone help me?
I followed this site: https://johncodeos.com/how-to-create-a-carousel-in-android-using-kotlin/
but in his case, he does the code in an AppCompatActivity class
I would like to do the same, only in a Fragment class
if possible instead of text I would like an image

you can use ViewPager2 in fragment without problems, but you should initialize ViewPager's adapter in onViewCreated method. If you want an image simply change TextView to ImageView in item_carousel.xml mentioned in article that you provided.

Related

Text field problems Xcode

I’m creating an app and need to make a signup/login page. I added a background using a picture and a zstack and on top I have the text and text fields. The text fields are showing up but not allowing me to add padding as well as there is no title text showing. Please help.my code
Did some more testing to find out that this happens whenever I use a textfield over an image. Not sure if this is a bug or not but it seems to be because as soon as the zstack is removed everything works.
At last ive discovered the issue, the text fields are extending way out of the canvas. Ive fixed the width of the textfield as a temporary solution but still looking for a way to fix this relative to the screen rather than the background as the field extends to the size of the image. Let me know if you can help as im just starting to use xcode!
I think its because the image cause canvas to be much more bigger and you use edgesIgnoringSafearea(.all)
Try to use on the image clipped() method and i think it will fix your issue with the padding.
And also try to add foregroundColor to the test fields

Interactive MapView annotation with straight lines between each annotation

I have a mapView with annotations on it.
I want to implement the ability to click on an annotation, and after clicking, the user see straight lines from the current clicked annotation to the others.
For example, if the user clicks on annotation 1, there will be straight lines from annotation 1 to annotation 2, 3 and the rest. The rule should be: touching an item on the map should show lines to the rest of the items on the map
I don't know how to get into it at all.
Any suggestions?
Here is an illustration.
I am not sure, what you wanna to do with just a straight line on a plain of a Map, but here is a complete example that you need to understand.
Just skip the last section of drawing the exact Route-Map, or else you will end up in making a real route.
Now the touch & detect annotation should be a simple logic to make a source & rest all as destination.
Hope that helps.

How to center a text view with Applescript Objective C?

I have a simple text view (which is inside a scroll view) and for the life of me I cannot make it center the text inside the text view. There is no choice in the inspector to center the text like there is when you use a normal text field. I have tried stuff like:
tell textView to setTextAlignment_(current application's setTextAlignment UITextAlignmentCenter)
But, obviously that fails. How is this done?
Try use:
tell textView to setAlignment_(current application's NSTextAlignmentCenter)

How to add comment box to page?

I am trying to model my "add comment" interface with what you see in the diagram below. However, I was unable to find such a UI element in the XCode library.
Is this a customized UI element? Or can I find a UI with the same look and feel as what you see in the diagram?
You can approximate it using a UIImageView (the silver gray background) and a UITextView on top of it which has a proper cornerRadius set. You'll need to:
#import <QuartzCore/QuartzCore.h>
in order to be able to set the cornerRadius property of the UITextView like this:
textView.layer.cornerRadius = 1.0f; // play around to see what gives you the above rounded effect to your needs.
Assuming you just want the textfield shape, you can use a UIImageView as background and have a textfield or textview on top of it accordingly...Now if you want that textview to expand thats another story, you can use strechableImageWithleftCapWidth: method on the image in order to be able to strech and expand it, and then you would need to create a custom UITextView class that expands as characters are typed in...

Core Animation - Page flip

I would like to 'bend' a view exactly like Flipboard app. I succeeded to flip an entire view, but not to bend it. My strategy is this: make a view/layer from half of the view I want to bend, add this to the view and flip this new view. So: how do I draw in a view/layer just half of another view?
Hey I recently used this code which works fine for me !!! You can get a flipboard like page animation with fold from center. It's concept is simple and it's easy to use. Just one class i.e .h .m file need to add in your project "AFKPageFliper".
https://github.com/mtabini/AFKPageFlipper
Hope this help for you too !!