我在我的Android應用程序上使用底部的工具欄,但我不知道如何使其項目具有相同的寬度,因此它們是對齊的。這是我的工具欄看起來像(所有項目都在左邊,它們之間沒有分離):如何對齊Ti.UI.Toolbar項目? (Android Appcelerator)
這是我想要實現(項目分離,並居中)什麼:
我試着將每個項目/視圖的寬度設置爲「33%」,但這不起作用。
我正在使用Titanium SDK 6.2.2 GA。請參閱我下面的代碼:
合金的xml:
<Toolbar width="Ti.UI.FILL" bottom="0" barColor="#639851" horizontalWrap="false">
<Items>
<View id="addView" class="bottomBtn" onClick="addDirection">
<ImageView class="icons" image="/icons/add.png" touchEnabled="false" />
<Label class="label" text="Add" touchEnabled="false" />
</View>
<View id="mapView" class="bottomBtn" onClick="showMap">
<ImageView class="icons" image="/icons/map.png" touchEnabled="false" />
<Label class="label" text="See map" touchEnabled="false" />
</View>
<View id="routeView" class="bottomBtn" onClick="calculateRoute">
<ImageView class="icons" image="/icons/optimize.png" touchEnabled="false" />
<Label class="label" text="Calculate" touchEnabled="false" />
</View>
</Items>
</Toolbar>
TSS:
".label" : {
color: "#212121"
}
".icons" : {
width: "24dp",
height: "24dp"
}
".bottomBtn" : {
layout: 'vertical',
width: Ti.UI.SIZE,
height: Ti.UI.SIZE,
backgroundColor: "#639851",
touchFeedback: true,
touchFeedbackColor: "#808080"
}
我嘗試使用上面的代碼,但我的意見/項目消失,工具欄高度被破壞:https://i.imgur.com/7rdhmQm.png – guillefix
請參閱我編輯的答案。我在我的電腦上試過了,它運行良好。感謝Nebu指出了保證金設置。 –