标签: button

具有自定义XML布局的按钮

是否可以创建具有自定义xml布局的按钮?

我有这个布局:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="wrap_content"
  android:padding="1dp"
  android:background="#7e7e7e">

 <RelativeLayout
   xmlns:android="http://schemas.android.com/apk/res/android"
   android:layout_width="fill_parent"
   android:layout_height="wrap_content"
   android:padding="10dp"
   android:background="#f9f9f9">

 <TextView
  android:id="@+id/TextView01" 
  android:layout_width="wrap_content" 
  android:layout_height="wrap_content"
  android:layout_alignParentLeft="true"
  android:text="ButtText"
  android:textColor="#000000">
 </TextView>

 <ImageView 
  android:id="@+id/ImageView01" 
  android:layout_width="wrap_content" 
  android:layout_height="wrap_content" 
  android:background="@drawable/arrow"
  android:layout_alignParentRight="true">
 </ImageView>

 </RelativeLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

现在我想在一个按钮上使用它.谁知道我怎么做到这一点?
我在想是否有Button.java文件扩展了Button.然后是setView(R.layout.mylayout.xml); ......但这很容易,而且显然不起作用

关心马丁

xml android button

8
推荐指数
2
解决办法
1万
查看次数

Facebook喜欢按钮:隐藏文字

我刚刚在我的网站上添加了一个类似Facebook的按钮,这是最基本的按钮,但你不能选择隐藏"注册以查看你的朋友喜欢的内容".文本.

因为按钮的区域太小,我不想要这个文本,因为它与旁边的其他文本重叠.

有没有办法隐藏这部分?我基本上只想要类似按钮,具有相同的功能.

facebook button facebook-like

8
推荐指数
2
解决办法
1万
查看次数

模拟器不显示按钮文本

我正在学习使用XCode 4.5.2构建iPhone应用程序,我发现了一些奇怪的东西.正如您在地址http://i.stack.imgur.com/purI8.jpg上看到的那样,其中一个按钮内的文本未显示在iOS6模拟器中.我还尝试在0和 - 的相同行中移动Enter按钮,但该行的所有三个按钮中的文本都消失了.任何人都知道这个问题的原因是什么以及如何解决它?这是代码:

#import "CalculatorViewController.h"
#import "CalculatorBrain.h"

@interface CalculatorViewController()
@property (nonatomic) BOOL userIsInTheMiddleOfEnteringANumber;
@property (nonatomic, strong) CalculatorBrain *brain;
@end

@implementation CalculatorViewController

@synthesize display;
@synthesize userIsInTheMiddleOfEnteringANumber;
@synthesize brain = _brain;

- (CalculatorBrain *)brain
{
    if (!_brain) _brain = [[CalculatorBrain alloc] init];
    return _brain;
}

- (IBAction)digitPressed:(UIButton *)sender
{    
    NSString *digit = [sender currentTitle];
    if (self.userIsInTheMiddleOfEnteringANumber) {
        self.display.text = [self.display.text stringByAppendingString:digit];
    } else {
        self.display.text = digit;
        self.userIsInTheMiddleOfEnteringANumber = YES;
    }
}

- (IBAction)enterPressed
{
     [self.brain pushOperand:[self.display.text doubleValue]];
     self.userIsInTheMiddleOfEnteringANumber …
Run Code Online (Sandbox Code Playgroud)

button ios-simulator ios6 xcode4.5

8
推荐指数
1
解决办法
616
查看次数

Javascript:: 导出到文本文件

<!DOCTYPE html>
<html>

<head>
    <title>&nbsp;</title>
    <meta charset=utf-8>
</head>

<body>

    <table>
        <tr>
            <th>A</th>
            <th>B</th>
            <th>C</th>
        </tr>
        <tr>
            <td>Line #1</td>
            <td>SLTD</td>
            <td>32</td>
        </tr>
        <tr>
            <td>Line #2</td>
            <td>MKTD</td>
            <td>68</td>
        </tr>
        <tr>
            <td>Line #3</td>
            <td>LRTD</td>
            <td>55</td>
        </tr>
        <tr>
            <td>Line #4</td>
            <td>HAD</td>
            <td>47</td>
        </tr>
    </table>

    <button>Export to text file</button>

    <script>
        var theFirstChilds = document.querySelectorAll('table tr td:first-of-type'), text, i;

        text = "";

        for (i = 0; i < theFirstChilds.length; ++i) {
            text = text + theFirstChilds[i].innerText;
        }

        console.log(text);

        var button = document.getElementsByTagName("button")[0];

        button.addEventListener("click", function() {
            //alert("I …
Run Code Online (Sandbox Code Playgroud)

html javascript export onclick button

8
推荐指数
1
解决办法
2万
查看次数

有没有办法改变 Antd 内部按钮的颜色?

我正在为我的应用程序使用 antd。我需要将默认主按钮的颜色从蓝色更改为灰色。似乎 antd 没有提供这样的选项。如何轻松更改按钮颜色?

css button antd

8
推荐指数
3
解决办法
2万
查看次数

How to return a Button from a function in SwiftUI?

I need to dynamically create a Button based on some parameters

func buildButton(parameter : Parameter) -> Button {
        switch (parameter){
            case Parameter.Value1:
                return Button(
                    action: {
                        ...
                },
                    label: {
                        ...
                }
            )
            case Parameter.Value2:
                return Button(
                    action: {...},
                    label: {
                        ...
                }
            )
        }
    }
Run Code Online (Sandbox Code Playgroud)

But the compiler gives me this error:

Reference to generic type 'Button' requires arguments in <...>. Insert '<<#Label: View#>>'

So if I click Fix, the function declaration becomes

func buildButton(parameter : Parameter) -> …
Run Code Online (Sandbox Code Playgroud)

button swift swiftui

8
推荐指数
1
解决办法
5768
查看次数

使用滑块按钮创建分段控件小部件 - Flutter

我如何创建类似的东西?:

演示:
演示

我知道颤振有

CupertinoSegmentedControl()
Run Code Online (Sandbox Code Playgroud)

但这会创建类似于标签的东西,没有什么像里面有按钮的开关那样滑动。

controls button flutter flutter-layout

8
推荐指数
1
解决办法
7538
查看次数

在 SwiftUi 中禁用默认按钮单击动画

如何禁用 SwiftUI 和 Swift 5 中的默认按钮单击动画?我尝试添加.animation(.nil)到按钮,没有任何更改。

我知道您可以执行以下操作:

Button(action: {}) { Capsule() }
.buttonStyle(NoAnim())

struct NoAnim: ButtonStyle {
func makeBody(configuration: Self.Configuration) -> some View {
    configuration.label
}
Run Code Online (Sandbox Code Playgroud)

有人知道更聪明的方法吗?

animation default button disable swiftui

8
推荐指数
2
解决办法
2625
查看次数

在新窗口中打开视图的按钮 SwiftUI 5.3 for Mac OS X

我想要一个按钮来打开一个新窗口并在 SwiftUI for MacOS 中加载一个视图(用于应用程序的首选项),但我不确定正确的方法。

我尝试创建一个函数并从按钮操作调用它,但在关闭新窗口时应用程序崩溃:

线程 1:EXC_BAD_ACCESS(代码=1,地址=0x20)

这是我的功能:

func openPreferencesWindow() {
    var preferencesWindow: NSWindow!
    let preferencesView = PreferencesView()
    // Create the preferences window and set content
    preferencesWindow = NSWindow(
        contentRect: NSRect(x: 20, y: 20, width: 480, height: 300),
        styleMask: [.titled, .closable, .miniaturizable, .resizable, .fullSizeContentView],
        backing: .buffered,
        defer: false)
    preferencesWindow.center()
    preferencesWindow.setFrameAutosaveName("Preferences")
    preferencesWindow.contentView = NSHostingView(rootView: preferencesView)
    preferencesWindow.makeKeyAndOrderFront(nil)
}
Run Code Online (Sandbox Code Playgroud)

这是我调用它的按钮:

Button(action: {
    openPreferencesWindow()
}) {
    Text("Preferences").font(.largeTitle).foregroundColor(.primary)
}
Run Code Online (Sandbox Code Playgroud)

我觉得应该在 AppDelegate 中构建窗口,但我不确定我会如何调用它。

macos window button nswindow swiftui

8
推荐指数
1
解决办法
2205
查看次数

如何在 vuetify 3 中创建 fab Button?

在 vuetify 2 中,它与<v-btn fab></btn>. 它如何与 vuetify 3 配合使用?

button floating-action-button vuetifyjs3

8
推荐指数
1
解决办法
4004
查看次数