我用的是RaisedButton这样的方式:
RaisedButton(shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(24.0)),
onPressed: null,
padding: EdgeInsets.all(12.0),
color: Colors.blue,
child: Text("Button", style: TextStyle(color: Colors.white)))
Run Code Online (Sandbox Code Playgroud)
他们决定RaisedButton弃用并ElevatedButton应该使用。但是,padding和shape属性缺失。如何获得相同的效果ElevatedButton?
import 'package:flutter/material.dart';
class AddPlaceScreen extends StatefulWidget {
static const routeName = '/add-place';
@override
_AddPlaceScreenState createState() => _AddPlaceScreenState();
}
class _AddPlaceScreenState extends State<AddPlaceScreen> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Add new Place data'),
),
body: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Text('User Inputs'),
ElevatedButton.icon(
onPressed: () {},
icon: Icon(Icons.add),
label: Text('Add Place'),
),
],
),
);
}
}
Run Code Online (Sandbox Code Playgroud)
在这里,我在页面底部的提升按钮下有一个空格,请提供任何解决方案来删除它。
我做了一个简单的应用程序。它有两个屏幕:onBoarding 和 homeScreen:
@Composable
fun DigitalBanking() {
var shouldShowOnBoarding by rememberSaveable { mutableStateOf(true) }
if (shouldShowOnBoarding) {
OnBoardingScreen {
shouldShowOnBoarding = false
}
} else {
MainScreen()
}
}
@Composable
fun OnBoardingScreen(
onClick: () -> Unit
) {
Surface {
Column(
modifier = Modifier.fillMaxSize(),
verticalArrangement = Arrangement.Top,
horizontalAlignment = Alignment.CenterHorizontally
) {
Box(
modifier = Modifier
.fillMaxSize()
.background(color = MaterialTheme.colors.onBackground)
)
{
Image(
painter = painterResource(id = R.drawable.starting_screen),
contentDescription = null,
modifier = Modifier
.fillMaxSize()
.padding(bottom = 160.dp)
)
Column( …Run Code Online (Sandbox Code Playgroud) 我想创建一个带有超链接的按钮Streamlit。我想也许可以使用st.button这种语法:[Click Here](https://stackoverflow.com)。但不幸的是这没有成功,它只显示文本,并没有将其作为超链接。我找到了这个解决方法,但这不再有效。我不想使用st.markdown超链接,因为这不会创建按钮。这是一个可重现的示例:
"""
# Streamlit app
"""
import streamlit as st
import pandas as pd
# Button with hyperlink
st.button('[Click Here](https://stackoverflow.com)')
Run Code Online (Sandbox Code Playgroud)
输出:
如您所见,它不会创建超链接。所以我想知道是否有人知道如何在 Streamlit 中创建带有超链接的按钮?
例如,我希望在 pdf 或 csv 文档的句子中间有一个下载按钮。这意味着句子中应该有一个小按钮,建议您可以下载文档,而不是在导航或侧栏中。这是一些可重现的代码:
---
title: "Download button in text Quarto"
format:
html:
code-fold: true
engine: knitr
---
I would like to have a download button [here]() for pdf or CSV document for example.
Run Code Online (Sandbox Code Playgroud)
我不确定是否可以使用downloadthis包在句子中实现一个干净的按钮,因为它应该位于带有文本的句子的中间。
我需要在页面底部放置三个按钮,我希望它们分别位于左角、中心和右上角。我确实创建了 HorizontalLayout,并在其中添加了按钮。我与各种对齐方式斗争了三天多,但无论我做什么,按钮仍然位于左上角。这是我的代码:
HorizontalLayout bottomLayout = new HorizontalLayout();
bottomLayout.setWidthFull();
bottomLayout.setHeight("82px");
bottomLayout.add(buttonA, buttonB, buttonC);
// bottomLayout.setAlignItems(Alignment.STRETCH);
bottomLayout.setAlignSelf(Alignment.END, buttonC);
bottomLayout.setAlignSelf(Alignment.START, buttonA);
bottomLayout.setAlignSelf(Alignment.CENTER, buttonB);
Run Code Online (Sandbox Code Playgroud)
请告诉我我做错了什么以及如何纠正。另外,我所有的按钮都是 80 像素高,前两个按钮看起来彼此垂直对齐,而第三个按钮看起来要高几个像素。我如何垂直对齐它们?
我有一个非常简单的视图,仅显示 a Text、 aShape和 aButton垂直堆叠在 a 中ScrollView。是Shapea且仅当是Capsule时才会有条件地显示。showCapsuletrue
struct ContentView: View {\n\n @State var showCapsule = true\n\n var body: some View {\n ScrollView {\n VStack(spacing: 16) {\n Text("Why, oh why? ")\n .font(.headline)\n if showCapsule {\n Capsule()\n .frame(maxWidth: .infinity)\n .frame(height: 100)\n .foregroundColor(.blue)\n }\n Button {\n showCapsule.toggle()\n } label: {\n Text(showCapsule ? "Hide" : "Show")\n }\n .buttonStyle(.bordered)\n }\n .frame(maxWidth: .infinity)\n .padding()\n }\n .animation(.default, value: showCapsule)\n }\n}\nRun Code Online (Sandbox Code Playgroud)\n我想将图像加载到ImageButton适配器中,这有时不起作用......我有一个带有 4 个条目的适配器,有时,按钮图像只加载了 2 次而不是 4 次。始终只在第一次创建适配器时......在屏幕旋转左右后,一切正常......但在第一次显示时,它无法正常工作......
具有 4 行的适配器仅在第一次创建时调用 2 次准备和两次加载...
以下是我的适配器getView:
@Override
public View getView(final int position, View convertView, ViewGroup parent)
{
if (convertView == null)
convertView = LayoutInflater.from(getContext()).inflate(R.layout.row_link, parent, false);
convertView.setTag(R.id.tag_pos, position);
ImageView iconRow = ViewHolder.get(convertView, R.id.icon);
final ImageButton btOpen = ViewHolder.get(convertView, R.id.btOpen);
// this NEVER fails
PicassoTools.getPicasso().load(item.getIconResId()).into(iconRow);
// this sometimes (at the first start) does not work reliable
PicassoTools.getPicasso().load(isAutoLinked ? R.drawable.linked : R.drawable.unlinked).into(new Target()
{
@Override
public void onPrepareLoad(Drawable d)
{
L.d(this, …Run Code Online (Sandbox Code Playgroud) 我有一个垂直LinearLayout和四个水平LinearLayouts. 每个水平布局包含 4 Buttons. 我希望Buttons在每个水平方向LinearLayout均匀地填充屏幕宽度。目前它看起来像这样:
Button每行的第一行占据所有宽度,Buttons每行的其他 3行不可见。有谁知道我该如何解决这个问题?
<LinearLayout
android:id = "@+id/ll_screen_bttns"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:orientation="vertical"
>
<LinearLayout
android:id="@+id/ll1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_weight = "1">
<Button
android:id="@+id/button0"
android:layout_width="fill_parent"
android:layout_height="@dimen/size"
android:background="@drawable/button"
android:onClick="ButtonOnClick"
android:tag="0"/
/>
<Button
android:id="@+id/button1"
android:layout_width="fill_parent"
android:layout_height="@dimen/size"
android:background="@drawable/button"
android:onClick="ButtonOnClick"
android:tag="0"
/>
<Button
android:id="@+id/button2"
android:layout_width="fill_parent"
android:layout_height="@dimen/size"
android:background="@drawable/button"
android:onClick="ButtonOnClick"
android:tag="0"
/>
<Button
android:id="@+id/button3"
android:layout_width="fill_parent"
android:layout_height="@dimen/size"
android:background="@drawable/button"
android:onClick="ButtonOnClick"
android:tag="0"
/>
</LinearLayout>
<LinearLayout
android:id="@+id/ll2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_weight = "1">
<Button
android:id="@+id/button4"
android:layout_width="fill_parent" …Run Code Online (Sandbox Code Playgroud) 我想知道使用 d3 向我的组元素添加按钮的最佳方法是什么。
我目前使用 d3 构建了我的视觉效果,看起来像:
<div>
<svg>
<g>
<rect>
</g>
<g>...</g>
</svg>
</div>
Run Code Online (Sandbox Code Playgroud)
所以我想知道如何在每个组元素中添加一个可点击的按钮。我的一些想法是:
g.append("a")
.append("image")
.attr("src", ...);
Run Code Online (Sandbox Code Playgroud)
或者
g.append("a")
.append("rect")
.attr(...)
Run Code Online (Sandbox Code Playgroud)
最终我希望按钮执行 onclick 事件。解决这个问题的最佳方法是什么?