简体   繁体   English

在Android中将文字加上图片+圆边分组

[英]grouping texts plus images + round edges in android

i was requested to make in android a view that groups several items like checkboxes or text views in vertical rows, separated by transparent dividers while the background is with a certain alpha level and the edges are round. 我被要求在android中创建一个视图,该视图将多个项目(如复选框或文本视图)分组为垂直行,并由透明分隔线分隔,而背景具有一定的alpha水平且边缘为圆形。

I thought of two solutions and i hope for some feedback on good\\bad or other solutions if you got'em. 我想到了两个解决方案,希望您能得到关于好/坏或其他解决方案的反馈。

  1. just use regualr linear layout but have a single style A that uses a 9 patch as background, includes padding,margins and whatever i need to make it look like what i want. 只需使用regualr线性布局,但具有使用9补丁作为背景的单一样式A,包括填充,边距以及我需要使其看起来像我想要的任何东西。 i then create another style A.up and A.down that represents the upper most and lower most items that will use a different 9-path with round corners. 然后,我创建另一个样式A.up和A.down,分别表示将使用带有圆角的9路径的最高和最低项目。
  2. inherit from linear layout, in the onMeasure and layoutChildren add to all the children some kind of space between them, i can create new attribute for it that can be customized in a style. 从线性布局继承,在onMeasure和layoutChildren中向所有子级之间添加某种空间,我可以为其创建新属性,并可以使用样式对其进行自定义。 i can override the dispatchDraw to paint the background for each view before it draws so i can paint my round borders, my only demand will be that each View added to this layout will have to be with transparent background. 我可以重写dispatchDraw在绘制每个视图之前为其绘制背景,以便绘制圆形边框,我唯一的要求是添加到此布局的每个视图都必须具有透明背景。

So what do you think ? 所以你怎么看 ?

Eventually i decided to use a List with customized divider. 最终,我决定使用带有自定义分隔符的列表。 It looks good, however a list got a very nasty bug when it comes down to items with states like buttons and clickable textViews, 看起来不错,但是当列表涉及状态如按钮和可点击的textView时,列表出现了一个非常讨厌的错误,

  1. you get no focus for the item and don't see the ornage bar 您对该项目没有重点,也看不到装饰栏
  2. you don't seem to get the evnets flowing to the children of the View in the list. 您似乎没有让evnet流入列表中View的子级。

I'm notsure how to resolve that one, i've seen numerous mails about it in the developres mailing list and here, most saying don't put statefull objects in a list. 我不确定如何解决这个问题,我在developres邮件列表中看到过很多关于它的邮件,在这里,大多数人说不要将有状态对象放在列表中。 So it mist not be the solution for me. 所以这不是我的解决方案。 Nest thing i'll try is extending the normal layouts to have a bar in their bottom and use regualr linear layout with round corners drawable. 我将尝试的嵌套方法是扩展常规布局以使其底部具有条形,并使用带有可绘制圆角的regularr线性布局。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM