gpt4 book ai didi

delphi - 如何防止多 View 不透明度影响Delphi中的子组件文本?

转载 作者:行者123 更新时间:2023-12-03 15:55:49 27 4
gpt4 key购买 nike

我在 Firemonkey 中使用 MultiView 和一些 TButton 按钮。 multiView 在 0.5 时不透明,这会导致按钮也不透明。

问题:有没有办法防止多 View 不透明度影响按钮文本?也就是说,按钮的文本将继续保持明亮的颜色,但按钮的“主体”将是不透明的。我见过一些具有此视觉功能的应用程序,但我不知道为此目的使用了哪些组件......

enter image description here

最佳答案

使用 TRectangle 作为菜单的基础,而不是使用 TMultiView。将其Align 设置为左​​侧,将Fill.Color 设置为$7FFFFFFF。前两个十六进制数字 (7F) 定义 Alpha channel (半透明度),其余的十六进制数字 (FFFFFF) 定义 RGB 颜色。这允许您将Opacity保留为1,但仍然具有半透明效果。这是 TMultiView 控件无法实现的。

对于每个项目,使用 TLayoutTImageTText 以及您喜欢的任何分隔线。使用普通的Align属性来设置项目。

最后,为 TLayout 设置 HitTest = True,为 TImage 设置 HitTest = False >TText 控件。这是为了启用鼠标单击或点击。

下面是我的测试,包括 .fmx 内容(已删除图像数据)和快照。

  object Rectangle1: TRectangle
Align = Left
Fill.Color = x7FFFFFFF
Size.Width = 200.000000000000000000
Size.Height = 210.000000000000000000
Size.PlatformDefault = False
object Layout1: TLayout
Align = Top
HitTest = True
Size.Width = 200.000000000000000000
Size.Height = 50.000000000000000000
Size.PlatformDefault = False
TabOrder = 0
object Image1: TImage
MultiResBitmap.Height = 128
MultiResBitmap.Width = 128
MultiResBitmap = <
item
Width = 128
Height = 128
PNG = {}
FileName = 'C:\tmp\Imgs\0.bmp'
end>
Align = Left
end
object Text4: TText
Align = Left
Position.X = 50.000000000000000000
Size.Width = 151.000000000000000000
Size.Height = 50.000000000000000000
Size.PlatformDefault = False
Text = 'Zero Hero'
TextSettings.Font.Size = 21.000000000000000000
TextSettings.Font.StyleExt = {00070000000000000004000000}
TextSettings.FontColor = claDarkblue
end
end
object Layout2: TLayout
Align = Top
HitTest = True
Position.Y = 50.000000000000000000
Size.Width = 200.000000000000000000
Size.Height = 50.000000000000000000
Size.PlatformDefault = False
TabOrder = 1
object Image2: TImage
MultiResBitmap.Height = 128
MultiResBitmap.Width = 128
MultiResBitmap = <
item
Width = 128
Height = 128
PNG = {}
FileName = 'C:\tmp\Imgs\1.bmp'
end>
Align = Left
end
object Text5: TText
Align = Left
Position.X = 50.000000000000000000
Size.Width = 151.000000000000000000
Size.Height = 50.000000000000000000
Size.PlatformDefault = False
Text = 'One More'
TextSettings.Font.Size = 21.000000000000000000
TextSettings.Font.StyleExt = {00070000000000000004000000}
TextSettings.FontColor = claDarkblue
end
end
object Layout3: TLayout
Align = Top
HitTest = True
Position.Y = 100.000000000000000000
Size.Width = 200.000000000000000000
Size.Height = 50.000000000000000000
Size.PlatformDefault = False
TabOrder = 2
OnClick = Layout3Click
OnMouseDown = Layout3MouseDown
object Image3: TImage
MultiResBitmap.Height = 128
MultiResBitmap.Width = 128
MultiResBitmap = <
item
Width = 128
Height = 128
PNG = {}
FileName = 'C:\tmp\Imgs\2.bmp'
end>
Align = Left
HitTest = False
end
object Text6: TText
Align = Left
HitTest = False
Position.X = 50.000000000000000000
Size.Width = 150.000000000000000000
Size.Height = 50.000000000000000000
Size.PlatformDefault = False
Text = 'Double Joy'
TextSettings.Font.Size = 21.000000000000000000
TextSettings.Font.StyleExt = {00070000000000000004000000}
TextSettings.FontColor = claDarkblue
end
end
object Layout4: TLayout
Align = Top
HitTest = True
Position.Y = 150.000000000000000000
Size.Width = 200.000000000000000000
Size.Height = 50.000000000000000000
Size.PlatformDefault = False
TabOrder = 3
object Image4: TImage
MultiResBitmap.Height = 128
MultiResBitmap.Width = 128
MultiResBitmap = <
item
Width = 128
Height = 128
PNG = {}
FileName = 'C:\tmp\Imgs\3.bmp'
end>
Align = Left
HitTest = False
end
object Text1: TText
Align = Left
HitTest = False
Position.X = 50.000000000000000000
Size.Width = 151.000000000000000000
Size.Height = 50.000000000000000000
Size.PlatformDefault = False
Text = 'Triple Fun'
TextSettings.Font.Size = 21.000000000000000000
TextSettings.Font.StyleExt = {00070000000000000004000000}
TextSettings.FontColor = claDarkblue
end
end
end

enter image description here

关于delphi - 如何防止多 View 不透明度影响Delphi中的子组件文本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47585746/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com