我在Firemonkey中使用MultiView和一些TButton按钮。多视图在0.5时是不透明的,这会导致按钮也不透明。
问题:有没有办法阻止MultiView不透明度影响按钮文本?也就是说,按钮的文本将继续使用鲜艳的颜色,但" body"按钮是不透明的。我已经看到了一些具有此视觉功能的应用程序,但我不知道为此目的使用了哪些组件......
答案 0 :(得分:2)
使用TMultiView
作为菜单的基础,而不是TRectangle
。将其Align
设置为左侧,将Fill.Color
设置为$7FFFFFFF
。两个第一个十六进制数字(7F)定义alpha通道(半透明),其余的十六进制数字(FFFFFF)定义RGB颜色。这允许您将Opacity
保留为一个,但仍具有半透明效果。使用TMultiView
控件无法做到这一点。
对于每件商品,请使用TLayout
,TImage
和TText
以及您喜欢的任何分隔线。使用普通Align
属性设置项目。
最后,为HitTest = True
设置TLayout
,为HitTest = False
和TImage
控件设置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
答案 1 :(得分:0)