我试图设置链接和按钮相等的样式.
为什么<button>和<a>在FF与下面的CSS声明diffently呈现:(注意按钮和两个不同的高度和长度的角落外边框).在Chrome中,它们呈现相同但具有外边框.在IE中它们被渲染为相同但没有圆形边框(IE8即不支持border-radius).
这是一个jsfiddle版本和继承人css
button, a
{
background-color: #7da7d8;
color: #e7e4ed;
border: 3px solid #f7f7f7;
border-radius: 8px 8px 8px 8px;
text-align:center;
font-weight: normal;
display: inline-block;
line-height: 1.2em;
margin: 4px;
width: 120px;
padding: 6px;
font-size:1.2em;
text-decoration:none;
cursor: pointer;
}
Run Code Online (Sandbox Code Playgroud)
请不要评论这样做的可用性问题 - 我有我的理由.
----------更新---------------从下面的评论我已经更新了css,在jsfiddle上查看它现在我只是错过了设置高度相等而且不知何故摆脱角落边界......
我想知道我是否可以将我的Button isEnabled绑定到我的StackPanel Children(有孩子).如果stackpanel有子项,那么我的按钮被启用,没有孩子我的按钮被禁用.目前我只是在代码中处理这个,但我开始想知道这是否是我可以绑定的东西.谢谢你的任何想法......
我是android的新手,我花了最近2天尝试前面的例子和在线解决方案,但我似乎无法理解它:(
我能够显示列表视图,从在线解析一些json并存储书名,书籍描述和书籍ID,并在列表视图中显示这些数据.我希望能够在ListView的每一行中放置一个"下载"按钮,每个按钮将对应于Click()上的书籍ID,动作监听器将通过将该ID附加到URL来下载该书.例如www.books.com/download_book1或/ download_book2 ....
这是我的代码.Catalogue.java类
public class Catalogue extends ListActivity {
private JSONObject json;
private ListView lv;
private ArrayList<Integer> alKey = new ArrayList<Integer>();
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); //icicle
setContentView(R.layout.shelflist);
ArrayList<HashMap<String, String>> mylist = new ArrayList<HashMap<String, String>>();
....
try{
JSONArray entries = json.getJSONArray("entries");
for(int i=0;i<entries.length();i++){
HashMap<String, String> map = new HashMap<String, String>();
JSONObject e = entries.getJSONObject(i);
alKey.add(e.getInt("key"));
map.put("id", String.valueOf(i));
map.put("title", "Title:" + e.getString("title"));
map.put("description", "Description: " + e.getString("description"));
mylist.add(map);
}
}catch(JSONException e) {
Log.e("log_tag", "Error parsing data "+e.toString()); …Run Code Online (Sandbox Code Playgroud) 嘿那里,我创建了一个UITextField,我想在它的右边添加一个(X)-CLEAR-按钮.用于清除已在文本字段中写入的内容的常规按钮.谢谢.
我无法弄清楚如何获得Button的文本的当前颜色.我知道它可能是这个,但不能完全弄清楚参数.
public static int getTextColor (Context context, TypedArray attrs, int def)...
Run Code Online (Sandbox Code Playgroud)
基本上我试图这样做
if(text is RED)
{make text BLACK}
else
{make text RED}
Run Code Online (Sandbox Code Playgroud)
我知道如何设置文本颜色.
有人错过了为简单按钮设置皮肤的简单方法吗?
<mx:Button x="10" y="10" label=""
upSkin="@Embed('imgs/mainButton_std.png')"
overSkin="@Embed('imgs/mainButton_over.png')"
downSkin="@Embed('imgs/mainButton_over.png')"
disabledSkin="@Embed('imgs/mainButton_std.png')"
creationComplete="mainButtonHitArea()"
width="75" height="75" id="menuButton" enabled="true"/>
//mainButtonHitArea() : Is a generic function that generates the hit area
Run Code Online (Sandbox Code Playgroud)
我遇到的问题是,这种创建带皮肤的简单按钮的方法正在逐步淘汰:事实上,Flex 4.5移动项目不再支持它.
所以问题是:是否有一种简单的方法来执行此操作,使用火花按钮(这被认为是新的方式).尽可能简单.
基本上我只需要一个带有2个图像的按钮:向下/向上和向上.我想让代码保持尽可能简单:新的蒙皮方法似乎真的为以前的例子提供了过多的线条.
我正在向ListActivity动态添加一个按钮.如下:
setContentView(R.layout.listview_singlegrey);
LayoutInflater inflater = (LayoutInflater)this.getSystemService
(Context.LAYOUT_INFLATER_SERVICE);
LinearLayout linear = (LinearLayout) findViewById(R.id.list_comment);
Button btAddComment = (Button)inflater.inflate(R.layout.bt_yellow,null);
FrameLayout.LayoutParams lyp1 = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,ViewGroup.LayoutParams.WRAP_CONTENT);
lyp1.gravity = Gravity.RIGHT;
btAddComment.setLayoutParams(lyp1);
btAddComment.setText("Añadir comentario");
Run Code Online (Sandbox Code Playgroud)
listview的LinearLayout是:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:orientation="vertical"
android:layout_height="fill_parent" android:id="@+id/list_comment"
android:paddingLeft="10dp" android:paddingRight="10dp" android:background="@drawable/fondomain">
<ListView android:id="@+id/android:list" android:listSelector="@android:color/transparent"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:divider="@layout/linedivider" android:dividerHeight="10px"
android:cacheColorHint="#0000" android:paddingTop="10dp"
/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
我正在膨胀的按钮布局是:
<?xml version="1.0" encoding="utf-8"?>
<Button xmlns:android="http://schemas.android.com/apk/res/android"
style="@style/wrapfill"
android:background="@layout/selectoryellowbutton" android:layout_gravity="right" android:padding="10dp"
android:textSize="16px" android:text="Añadir comentario" android:textStyle="bold" android:textColor="@color/darkergray">
</Button>
Run Code Online (Sandbox Code Playgroud)
正如您所看到的,我已尝试在代码和按钮中设置layout_gravity参数,但它们都不起作用.我仍然显示屏幕左侧的按钮.似乎布局参数不起作用.但是,如果我为宽度设置fill_parent,我会在整个屏幕上显示按钮,我希望按钮包裹文本并对齐屏幕右侧.