我在设置按钮高度时遇到了问题.基本上我无法让它跨浏览器.使用Firefox,它没有任何理由高于正常水平.
这是一个截图(Firefox,Safari和Opera,按此顺序):

这里的代码:http://jsfiddle.net/TMUnS/2/
我也尝试添加一些我在网上发现的特定声明,但实际上它们只是略微降低了高度,但是,它们不一样(按相同的顺序):

这里的代码是:http://jsfiddle.net/TMUnS/4/.
我怎么能解决这个问题?
在这里你是我的问题:我想在android中做一个看起来像这个网格的布局:

为此,我创建了这个布局:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/RelativeLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:orientation="vertical" >
<TableLayout
android:id="@+id/tableLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TableRow
android:id="@+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.3">
<Button
android:id="@+id/clientimain"
android:layout_width="0dip"
android:layout_weight="1" android:layout_height="fill_parent"/>
<Button
android:id="@+id/button1"
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text="Button" />
</TableRow>
<TableRow
android:id="@+id/tableRow2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.3" >
<Button
android:id="@+id/button2"
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text="Button"/>
<Button
android:id="@+id/button6"
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text="Button" />
</TableRow>
<TableRow
android:id="@+id/tableRow3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.3" >
<Button
android:id="@+id/button3"
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text="Button"
/>
<Button
android:id="@+id/button7"
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text="Button"
/>
</TableRow>
</TableLayout>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
所以基本上它由表格布局中的6个按钮组成,正确设置了权重属性(或者我希望如此!).结果看起来很好,直到我尝试设置每个按钮的背景属性.在这种情况下,按钮获取放入的图像的高度(宽度正常).例如,如果我设置大小为96px …
我想扩大我的按钮高度.我试图给行充气,但它没有任何想法?
查看我的更新代码与相对布局和tablelayot ...
尝试扩大行和tablelayout相同的结果......
我试过enl XML
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/black_bg"
android:layout_centerVertical="true">
<TableLayout android:id="@+id/row1"
android:layout_width="fill_parent"
android:layout_height="45dip"
android:paddingRight="5px"
android:paddingLeft="5px"
android:paddingTop="15px"
android:paddingBottom="5px"
android:layout_weight="1">
<TableRow
android:layout_weight="1"
android:layout_height="50dip">
<ToggleButton android:id="@+id/btn_service_plus"
android:layout_marginRight="4px"
android:textColor="@android:color/white"
android:textStyle="bold"
android:textSize="12dip"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:text="1"
android:layout_weight="1"
/>
<Button
android:layout_marginLeft="4px"
android:layout_marginRight="4px"
android:textColor="@android:color/white"
android:textStyle="bold"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:textSize="12dp"
android:layout_weight="1"
/>
<Button
android:layout_marginLeft="4px"
android:layout_marginRight="4px"
android:textColor="@android:color/white"
android:textStyle="bold"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:textSize="12dp"
android:layout_weight="1"
/>
<ToggleButton
android:layout_marginLeft="4px"
android:textColor="@android:color/white"
android:textStyle="bold"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:textSize="12dp"
android:layout_weight="1"
android:background="@drawable/menu_button_layout"/>
</TableRow>
Run Code Online (Sandbox Code Playgroud) 这是我的代码:
<form name='frm' id='frm' action='load.asp' method='post' onSubmit='return OnSubmit(this)' style='margin-top:15px'>
<input type='submit' name='send' id='send' onclick="this.disabled=true;return true;" value='Send' title='test'>
</form>
Run Code Online (Sandbox Code Playgroud)
我希望我的onsubmit函数被执行,我希望页面被提交.在我的网站上,没有提交,也没有功能
我试图在这里复制它,但表格似乎被张贴,我的功能永远不会被执行... http://jsfiddle.net/V7B3T/1/
我不知道什么时候应该重新激活按钮.
我应该在document.ready或onSubmit函数中执行此操作吗?
因此,如果有人可以修复小提琴:)然后我将它与我的代码进行比较.我想:我迷路了
谢谢大家
默认情况下,我们在警告对话框中获得两个或三个水平对齐的按钮.是否可以在警报对话框中将它们垂直对齐?
我想为我的应用实现一个三向滑动按钮.在第一个位置它应该显示一种颜色,在中心它应该显示另一种颜色,在结束位置它应该再次改变颜色.在这里,我正在为此提供图像.



我该如何实现呢?
好吧,我会这样说的.
我有一个2列的表.第一列具有项目名称,第二列包含x个徽标/指示符(ImageButtons).几个项目可以具有相同的徽标/指示符.
我的问题是我可以为同一个ID分配几个ImageButtons吗?我试过android:id="@+id/logo1"在第一次使用然后"android:id=@id/logo1"在以下所有情况下使用.但这似乎不起作用.我可以为每个按钮指定一个不同的ID,然后将它们分配给同一个View,但如果我可以为所有类似的徽标/指标重复相同的ImageButton id,那将会更容易.
我正在制作游戏,我有一个选项页面可以打开或关闭音乐.我想覆盖后退按钮,以便它返回到主页,你会明白为什么当你看到我的代码时:
public class OptionsActivity extends Activity {
private boolean isMyServiceRunning(String serviceCanonicalClassName) {
ActivityManager manager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
if (serviceCanonicalClassName.equals(service.service.getClassName())) {
return true;
}
}
return false;
}
Intent i; // Handles MyMusicService.java
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.options);
final TextView tSound = (TextView) findViewById(R.id.textView2);
final Button saveBtn = (Button) findViewById(R.id.optSaveBtn);
final Button tblBtn = (Button) findViewById(R.id.tableBtn);
i=new Intent(this, MyMusicService.class);
final ToggleButton soundOption = (ToggleButton) findViewById(R.id.soundPref);
boolean musicPlays = isMyServiceRunning(MyMusicService.class.getCanonicalName());
soundOption.setChecked(musicPlays);
if(musicPlays==true){
tSound.setText("On");
} …Run Code Online (Sandbox Code Playgroud) 这是一个非常基本的问题,但我相信那里有人知道为什么.在HTML中,当我单独创建一个按钮元素,并且不给它onclick并且没有jQuery时.click(),按钮将不执行任何操作.完善.但是当我这样做但是<form>元素内的按钮时,它会尝试将所有表单元素的GET数据发送到我网站的根地址?它为什么这样做?我没有把它作为提交按钮,甚至没有定义method或action在那个表格?
提前感谢您的信息!
**编辑**
这就是我为解决问题所做的工作.对于里面的按钮<form>,使用:
<button type="button"></button>
Run Code Online (Sandbox Code Playgroud)
默认情况下它不会做任何事情.
我陷入了Android的一个奇怪问题 - 我希望有一个看起来像这样的按钮:
|-----------------------------------------------------------------------|
| [icon] <5px> [text text text] |
|-----------------------------------------------------------------------|
Run Code Online (Sandbox Code Playgroud)
并且组([icon] <5px> [文本文本文本])应居中.请注意,5px仅用作占位符,用于图标和文本之间的任何填充
我在这里找到了一些答案或多或少地围绕设置背景(我不想做因为我有另一个背景)或使用android:drawableLeft属性来设置图标.
但是看起来像setCompoundDrawablesWithIntrinsicBounds方法的文档有点误导(见这里).它声明图像位于TEXT的左/右/上/下侧,这是不正确的.图标位于按钮的相应侧.例如:
设置android:drawableLeft属性将图标放在最左边的位置并获取此信息(使用重力CENTER):
|-----------------------------------------------------------------------|
| [icon] [text text text] |
|-----------------------------------------------------------------------|
Run Code Online (Sandbox Code Playgroud)
或者这个(重力为左):
|-----------------------------------------------------------------------|
| [icon] [text text text] |
|-----------------------------------------------------------------------|
Run Code Online (Sandbox Code Playgroud)
两个都是丑陋的地狱:(
我找到了一个看起来像这样的解决方法:
public static void applyTextOffset(Button button, int buttonWidth) {
int textWidth = (int) button.getPaint().measureText(button.getText().toString());
int padding = (buttonWidth / 2) - ((textWidth / 2) + Constants.ICON_WIDTH + Constants.ICON_TO_TEXT_PADDING);
button.setPadding(padding, 0, 0, 0);
button.setCompoundDrawablePadding(-padding);
}
Run Code Online (Sandbox Code Playgroud)
它或多或少有效,但由于以下原因,我不喜欢它:
难道没有更优雅的解决方案吗?