2011-03-19 62 views

回答

9

訣竅是創建另一個視圖,其中包含邊框的尺寸並將imageView放在旁邊...這是一個醜陋的黑客,但我見過它的唯一方法

+0

謝謝 - 是的,這就是我最後做,並能正常工作。 – Dogweather 2011-03-20 04:15:31

0

我知道這是一個老問題 - 但我想我會添加我今天發現的替代方案。

就像醜陋......但也許更簡單。

我需要用分隔符在屏幕上創建一個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> 

/約翰

0

做一個 「查看」 上面。並使「視圖」顏色作爲'backgroundColor'

0

另一個醜陋的黑客。在底部放置背景漸變。您必須先指定高度,並且線條不會100%固定,但您不會在設備上注意到它。

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