【问题标题】:Setting a border on just one side of a View?在视图的一侧设置边框?
【发布时间】:2011-03-19 00:10:01
【问题描述】:

有没有人能够在视图上做与左边框等效的操作? (我想在 ImageView 的一侧创建一个边框。)

【问题讨论】:

    标签: titanium appcelerator


    【解决方案1】:

    诀窍是创建另一个具有边框尺寸的视图并将 imageView 放在它旁边...这是一个丑陋的 hack,但我见过它完成的唯一方法

    【讨论】:

    • 谢谢 - 是的,这就是我最终所做的,而且效果很好。
    【解决方案2】:

    我知道这是一个老问题 - 但我想我会添加我今天找到的替代方案。

    同样丑陋....但也许更简单。

    我需要在屏幕上创建一个由 4 个图标组成的栏,并带有分隔符。我所做的是创建一个作为容器并在这 4 个标签内(其中包含一个)。我将它们设置为左侧:0、25%、50% 和 75%。然后我将每个嵌入的宽度设置为 24.8%,并将容器的背景颜色设置为我想要的任何颜色。

    例子:

    <View id="tb1" bottom="0" height="45dp" width="100%" backgroundColor='#99cc33'>
        <View height="45dp" left="0" width="24.8%" backgroundColor='#363636'>
            <ImageView width="40dp" image="/images/trip1.png"/>
        </View>
        <View height="45dp" left="25%" width="24.8%" backgroundColor='#363636'>
            <ImageView width="35dp" image="/images/trip2.png"/>
        </View>
        <View height="45dp" left="50%" width="24.8%" backgroundColor='#363636'>
            <ImageView height="40dp" image="/images/trip3.png"/>
        </View>
        <View height="45dp" left="75%" width="25%" backgroundColor='#363636'>
            <ImageView height="35" image="/images/trip4.png"/>
        </View>
    </View>
    

    /约翰

    【讨论】:

      【解决方案3】:

      对其进行“查看”。并将您的“视图”颜色设为“背景颜色”

      【讨论】:

        【解决方案4】:

        又一个丑陋的黑客。在底部放置一个背景渐变。您必须先指定高度,这条线不会是 100% 实心的,但您不会在设备上注意到它。

        "TextField": { height: 44, backgroundGradient: { type: "linear", startPoint: { x: 0, y: 43 }, endPoint: { x: 0, y: 44 }, colors: [ "white", "#ccc" ] } }

        【讨论】:

          猜你喜欢
          • 2019-07-06
          • 2021-06-17
          • 2013-03-02
          • 2012-06-29
          • 1970-01-01
          • 2015-06-19
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多