i have a class that extend: JSQLoadingPhotoMediaItem, all works fine expected that in my chat i do not use image for bubble, but i have a background color and radius for textView inside the bubble, if i use the class i obtain this:
The first one is the textView of the cell with a color background, the second one is a view that i return from class with this code:
view = UIView(frame: CGRect(x: 0, y: 0, width: UIScreen.mainScreen().bounds.width, height: 38))
view!.backgroundColor = UIColor(red:0.89, green:0.98, blue:0.78, alpha:1)
view!.layer.cornerRadius = CGFloat(9)
view!.layer.masksToBounds = true
in a function
override func mediaView() -> UIView!
How can i give the same right margin to my custom class? or if for example would like to have a view of custom class aligned center?
Thanks!
I also had the same problem. To get the same margin for my bubbles I resorted to using the same JSQMessagesMediaViewBubbleImageMasker from JSQMessagesMediaViewBubbleImageMasker.h in my custom media view
//apply mask to your view
[JSQMessagesMediaViewBubbleImageMasker applyBubbleImageMaskToMediaView:view isOutgoing:self.appliesMediaViewMaskAsOutgoing];
You can create a category of JSQMessagesMediaViewBubbleImageMasker and extend it however you wish, there was a particular case where I needed a specific color for the border of the bubble.
Thanks! i found a solutions, i have a clear background for the main view, and inside another subview with right or left margin based on sender, backgroundColor and corner radius!
Related
I'm trying to make a TextField like in the image using Jetpack Compose.
So far no luck in finding a easy way.
The label must stay inside the outline, if I use OutlinedTextField there is no way to customise that. If I use the TextField which has the label on the inside there is no outline when selected, just the line below the textfield.
Also I need to add a shadow/glow effect with a custom color, here seen in gold.
I'm stumped..
Any thoughts?
You can do this by creating a Row with a Modifier.drawBehind that uses native paint to draw blur with color as in this image, the one with pink background has blur with same background color for shadow for instance, you can check the code for drawing colored blur here.
val myColor = color
.copy(alpha = shadow.alpha)
.toArgb()
val transparent = color
.copy(alpha = 0f)
.toArgb()
frameworkPaint.color = transparent
frameworkPaint.setShadowLayer(
radius,
dx,
dy,
myColor
)
it.drawRoundRect(
//...
paint = paint
)
It draws a shape behind you can draw a shape with stroke.
For the label and input create a Column with Modifier.weight() to use space inside row other than space reserved for Icon with close image.
Instead of TextField you can use a BasicTextfield which doesn't have default padding, however you can achieve the same thing with TextField too, but you will need to set colors to transparent to remove indicator line, it has some default padding you might not want to have.
TextField(
colors = TextFieldDefaults.textFieldColors(
focusedIndicatorColor = Color.Transparent,
unfocusedIndicatorColor = Color.Transparent,
disabledIndicatorColor = Color.Transparent
)
)
I am facing with a specific problem with Glide.
I am trying to put top left / right corner but I dont know how to do this.
I have this following code but it for all corner :
#BindingAdapter("imageUrl")
#JvmStatic
fun setImageUrl(imageView: ImageView, imageUrl: String) {
var requestOptions = RequestOptions()
requestOptions = requestOptions.transforms(CenterCrop(), RoundedCorners(16))
Glide.with(imageView.context).load(imageUrl).apply(requestOptions).into(imageView)
}
}
Do you have any solution?
NB : I found this following website https://thedeveloperworldisyours.com/android/rounded-corners-with-glide/
But I would like to know if they have another way.
Not using glide But, This link might be helpful -> Android UI: creating imageview with rounded top corners in android - http://android--kotlin.blogspot.com/2019/02/android-ui-creating-imageview-with-rounded-top-corners.html
Its using the drawable corner frame in src and setting image in the background of the ImageView to create rounded top corners. frame drawable here has rectangle shape with radius and negative margin. So image is overridden by frame drawable from top corners.
I would like to create a smart caption as SoundCloud app did.
See the attachment below,
These two captions:
- •PAN•
- Berlin, Germany
are what I want create.
These captions seem to be executed by sizeToFit or sizeThatFits. However, if using sizeThatFits with background colour (by NSBackgroundColorAttributeName), you won't get padding both before the first and after the last letters and top and bottom paddings as well.
The caption will be organised the exact fit size as these letters.
Anyway, what I would like to do is the exact same caption like the attachment picture.
Cheers,
You have two approaches here. One is to add a bit of padding after calling sizeThatFits. The other is to prepend and append a space to your label title.
The right way about adding the padding, though, would be to extend UILabel and on your subclass, override the method textRectForBounds:limitedToNumberOfLines:. In there, just call the same method on super passing the bounds you receive, only smaller.
I know is an old question but i was looking for the same effect that SoundCloud has on its labels.
here is the subclassing of uilabel
import UIKit
class LabelPine: UILabel {
override func drawTextInRect(rect: CGRect) {
let insets = UIEdgeInsets.init(top: 5, left: 0, bottom: 5, right: 3)
super.drawTextInRect(UIEdgeInsetsInsetRect(rect, insets))
}
override func textRectForBounds(bounds: CGRect, limitedToNumberOfLines numberOfLines: Int) -> CGRect {
super.textRectForBounds(bounds, limitedToNumberOfLines: 0)
return CGRectInset(self.attributedText!.boundingRectWithSize(CGSizeMake(999, 999), options: .UsesLineFragmentOrigin, context: nil), -5, -5)
}
}
And here is the implementation on the respective class:
labelNombre = LabelPine()
labelNombre?.text = nombreUser
labelNombre?.frame = CGRectMake(10, nombrePos.Yo, nombrePos.ancho, nombrePos.alto)
labelNombre?.font = UIFont(name:"Hiragino Sans W3",size: 19)!
labelNombre?.textAlignment = .Left
labelNombre?.backgroundColor = UIColor(white: 1, alpha: 0.5)
labelNombre?.textColor = colorBlentUIColor
labelNombre?.sizeToFit()
header?.addSubview(labelNombre!)
Take notice i call sizeToFit().
I want to add an button in right side of tableview row, I have seen rightImage property in UI.TableViewRow. Is it possible to override the image view or can we add button under rightImage
rowObject.rightImage.add(mybutton);
In your TableViewRow, create a globalView with horizontal layout
var globalView = Ti.UI.createView({
width: "100%",
layout: "horizontal",
...
});
Then create 2 other views, the leftView (width equals to 80% for example) and the rightView which contains a button (set the width to 20%), then add the leftView and the rightView to your globalView.
globalView .add(leftView);
globalView.add(rightView);
Make sure that you set correctly the height for your components.
Is it possible to use a custom color or image for the white dot of the pagingControl in a Titanium.UI.Scrollableview?
var scrollableView =Titanium.UI.createScrollableView({
views:[view1,view2,view3],
showPagingControl:true,
pagingControlHeight:30,
pagingControlColor:'transparent',
width : 200,
height : 90,
left : 120,
top:40,
maxZoomScale:2.0,
currentPage:0
});
Answer (as you said) found on http://developer.appcelerator.com/question/130397/color-pages-dot-in-a-titaniumuiscrollableview#227004 :
sorry, i dont have an example.. but here is it:
create a container view.
then create the small "dot" views, and add them to the container view. set the positions.
there is an event, when the scrollable view "scrolls" or changing.. and you can set the small dot view to active (of course you should set up the active state as well)