我正在尝试重新创建一个用 React Native 制作的按钮,它的每一面都有不同的颜色,给人一种轮廓分明的效果,有点像 Photoshop 斜角和浮雕,但也有圆角。目前,我在按钮外部有一个容器,上面有边框,在内部我正在使用RawMaterialButton
. 容器的代码是这样的:
Container(
BoxDecoration(
border: Border(
left: BorderSide(
color: Colors.black,
width: 1.0,
),
top: BorderSide(
color: Colors.black,
width: 1.0,
),
),
),
)
Run Code Online (Sandbox Code Playgroud)
如何使该边框/容器的角变圆?
像这样但有圆角:
我已经创建了一个圆形按钮,在这种情况下RawMaterialButton
,我正尝试使用CustomPaint
它在其中心创建一个三角形,但这ShapesPainter
并不是为ClearButton'. I tried other buttons but couldn't get any of them to accept
ShapesPainter 类定义的。
RawMaterialButton(
child: CustomPaint(
painter: ShapesPainter(),
child: Container(
height: 40,
),
),
onPressed: onPressed,
constraints: BoxConstraints.tightFor(
width: 90.0,
height: 90.0,
),
shape: RoundedRectangleBorder(),
fillColor: Colors.transparent,
)
Run Code Online (Sandbox Code Playgroud)
应该使用哪种按钮类型?ShapesPainter
或者如何创建一个中心为三角形或其他形状的圆形按钮?
这是我尝试创建的按钮,如您所见,它基本上是一个带有三角形的圆形按钮。
我想传入一个值来将起始动画值设置为 1.0 而不是从 0 开始,但我不知道这是如何实现的。
class AnimatedIconButton extends StatefulWidget {
AnimatedIconButton(this.img, this.start);
final String img;
final double start;
@override
_AnimatedIconButtonState createState() => _AnimatedIconButtonState();
}
class _AnimatedIconButtonState extends State<AnimatedIconButton>
with TickerProviderStateMixin {
AnimationController _controller;
Animation _animation;
void animateButton() {
if (_animation.value == 0)
_controller.forward();
else
_controller.reverse();
}
@override
void initState() {
super.initState();
_controller = AnimationController(
duration: Duration(milliseconds: 300),
vsync: this,
);
_animation =
CurvedAnimation(parent: _controller, curve: Curves.easeOutQuad);
_controller.addListener(() {
setState(() {});
});
_animation.value = widget.start;// does not work
}
@override
void …
Run Code Online (Sandbox Code Playgroud) <button id='0' value="23" name='process'>Click 0</button>
<button id='1' value="45" name='process'>Click 1</button>
<button id='2' value="66" name='process'>Click 2</button>
<button id='3' value="88" name='process'>Click 3</button>
<button id='4' value="92" name='process'>Click 4</button>
$('#id').click(function(){
$.ajax({
url: "test.php",
data: {0:123},
processData: false,
contentType: 'application/json'
});
});
Run Code Online (Sandbox Code Playgroud)
我不是很熟悉ajax,但我想用它来避免重新加载页面,这是我正在使用的php正在发生的事情.我需要在单击其中一个按钮时通过ajax发送数据.每个按钮需要发送一个唯一键(id)和一个简单的数值.
不确定如何使用Ajax完成关于通过每次点击发送独特信息以及如何为不同按钮触发不同结果的方式.
我在JSON文件中有密钥,并且在使用密钥处理时不按数字顺序排列.有任何解决这个问题的方法吗?
$.getJSON("file.json", function(thedata) {
var items = [];
$.each(thedata, function(key, val) {
items.push(key);
});
Run Code Online (Sandbox Code Playgroud)
JSON文件:
"3.5":"some data",
"8":"some data",
"13":"some data",
"17.5":"some data",
"18":"some data",
Run Code Online (Sandbox Code Playgroud)
它们的密钥将按此顺序通过: 8, 13, 18, 3.5, 17.5
不知道为什么这行不通,因为我显然可以这样删除其他符号,但这是:str = str.replace('¥', '');
无法删除有问题的符号¥。任何想法如何删除这个东西?
我也尝试过这个str = str.replace(/¥/g, '');
,但是str = str.replace(/\¥/g, '');
没有用。
显然,我可以通过敲敲字符串中的第一个字符来删除它,但是我认为必须有一种方法可以真正检测到该东西,以防万一它不在最前面并且我需要将其删除。
我有一个HBox
内部 a VBox
,虽然大多数问题似乎都在问如何使用它所包含的HBox
整个宽度VBox
,但我要求相反。我的里面有按钮,其HBox
数量不断变化,因此HBox
应该不断改变它的大小,但是在向 中添加背景颜色后,HBox
很明显它占据了 的整个宽度VBox
,使其无法居中。
它目前类似于顶部示例,但我需要它类似于底部示例:
并使用
HBox.setHgrow(wordButtonsBox, Priority.NEVER);
Run Code Online (Sandbox Code Playgroud)
也没有改变任何东西..
public class CentreStuff extends Application {
@Override
public void start(Stage primaryStage) {
primaryStage.setScene(new Scene(createContent()));
primaryStage.show();
}
private Region createContent() {
HBox buttonBox1 = new HBox(new Button("Button1"), new Button("Button2"), new Button("Button3"), new Button("Button4"));
buttonBox1.setStyle("-fx-border-color: red;");
VBox results = new VBox(10, buttonBox1);
return results;
}
Run Code Online (Sandbox Code Playgroud)