简体   繁体   English

Appcelerator样式按钮图像Android

[英]Appcelerator Style Button Image Android

I have a piece of code which generates the button: 我有一段代码生成按钮:

var call_buttons = Titanium.UI.createButton({
    id: resultNodeID,
    title: resultNodeTitleNoQuotes + ", " + "Rating: " + ratings,
    font: { fontSize:23 },
    top: 1, 
    left: '3%',
    width: '94%', 
    height: '94%',
    image : 'star.png' 
 });

And on the app it looks like this: 在应用程序上,它看起来像这样: Android按钮

How do I style the star so it moves to the right hand side of the android button, not the left? 如何设置星星的样式,使其移动到android按钮的右侧,而不是左侧? I have read the documentation ( http://docs.appcelerator.com/platform/latest/#!/api/Titanium.UI.Button ) but can not find anything relating to the position of the image inside a button. 我已经阅读了文档( http://docs.appcelerator.com/platform/latest/#!/api/Titanium.UI.Button ),但是找不到与按钮内图像位置有关的任何内容。

The goal is to place the star where the word "Rating" is. 目的是将星星放置在“评级”一词的位置。

The image property only allows the image placed to the left of the button title. image属性仅允许将图像放置在按钮标题的左侧。 If you want to place an image to the right, I would suggest creating a view that acts like a button (attach a click event to the view) then place your label to the left and an image to the right inside the view to get the look you want. 如果要将图像放置在右侧,建议创建一个像按钮一样的视图(将点击事件附加到视图上),然后将标签左侧放置在图像内,右侧放置在图像内以获取看起来你想要的。

Another option would be to use an Attributed String as title and use a Icon Font for the star. 另一种选择是使用“属性字符串”作为标题,并为星标使用“图标字体”。 But... Titanium's button does not support Attributed String. 但是... Titanium的按钮不支持属性字符串。

You might want to do a Feature Request Appcelerator JIRA . 您可能需要做一个功能请求加速器JIRA Check if it has already been requested before you create a new ticket. 在创建新票证之前,请检查是否已请求该票证。 Refer to this question and also link back to the ticket here so that others can watch it with you. 请参考此问题,然后在此处链接回到票证,以便其他人可以和您一起观看。

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

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