是否可以创建具有自定义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); ......但这很容易,而且显然不起作用
关心马丁
我刚刚在我的网站上添加了一个类似Facebook的按钮,这是最基本的按钮,但你不能选择隐藏"注册以查看你的朋友喜欢的内容".文本.
因为按钮的区域太小,我不想要这个文本,因为它与旁边的其他文本重叠.
有没有办法隐藏这部分?我基本上只想要类似按钮,具有相同的功能.
我正在学习使用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) <!DOCTYPE html>
<html>
<head>
<title> </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) 我正在为我的应用程序使用 antd。我需要将默认主按钮的颜色从蓝色更改为灰色。似乎 antd 没有提供这样的选项。如何轻松更改按钮颜色?
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) 我如何创建类似的东西?:
我知道颤振有
CupertinoSegmentedControl()
Run Code Online (Sandbox Code Playgroud)
但这会创建类似于标签的东西,没有什么像里面有按钮的开关那样滑动。
如何禁用 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)
有人知道更聪明的方法吗?
我想要一个按钮来打开一个新窗口并在 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 中构建窗口,但我不确定我会如何调用它。
在 vuetify 2 中,它与<v-btn fab></btn>. 它如何与 vuetify 3 配合使用?