草庐IT

my-button

全部标签

dart - 如何正确启用/禁用 Flutter 的 Button

经研究,当onPressed为null时,Flutter的Button会自动禁用。但是,由于我需要的测试功能,我不得不放置一个箭头函数()=>,这似乎不会触发onPressed实际上为null,而是将null作为值返回。因此,当textField为空时,当前按钮什么都不做(null)。如果textField为空,我的目标是完全禁用它(灰色)。onPressed:()=>(_textController.text.isNotEmpty)?_addNewPair():null,showDialog(context:this.context,builder:(BuildContextcont

button - 如何在 Flutter 中为 Button 设置边距

我只是在Flutter中创建一个表单。我无法设置按钮的上边距。class_MyHomePageStateextendsState{Stringfirstname;Stringlastname;finalscaffoldKey=newGlobalKey();finalformKey=newGlobalKey();@overrideWidgetbuild(BuildContextcontext){returnnewScaffold(key:scaffoldKey,appBar:newAppBar(title:newText('Validatingforms'),),body:newPadd

flutter : Custom Radio Button

如何在Flutter中创建这样的自定义单选按钮组 最佳答案 这是完整的代码classCustomRadioextendsStatefulWidget{@overridecreateState(){returnnewCustomRadioState();}}classCustomRadioStateextendsState{ListsampleData=newList();@overridevoidinitState(){//TODO:implementinitStatesuper.initState();sampleData.add

android - flutter : How can I add divider between each List Item in my code?

如何在列表中添加分隔符?我使用FlutterforAndroid。我想在每个列表项之间添加一个分隔线,我想为分隔线着色并添加样式。我尝试添加newdivider();但出现错误。我也试过returnnewdivider();.这是我的应用程序的屏幕截图:这是我的代码:import'package:flutter/material.dart';import'package:flutter/foundation.dart';voidmain()=>runApp(constMyApp());classMyAppextendsStatelessWidget{constMyApp();@over

button - 如何更改 flutter Material 按钮的字体大小?

如何更改Material按钮的字体大小...有更好的方法吗?newMaterialButton(height:140.0,minWidth:double.infinity,color:Theme.of(context).primaryColor,textColor:Colors.white,child:newText("materialbutton"),onPressed:()=>{},splashColor:Colors.redAccent,), 最佳答案 Flutter中的小部件架构使这变得非常简单:MaterialButton

Android : Showing keyboard moves my components up, 我想隐藏它们

我添加了一个带有一些按钮的LinearLayOut我的屏幕是它自己的RelativeLayOut这是线性布局管理器的代码问题来了:顶部有一个EditText组件,它会在屏幕上弹出一个软键盘,并将我的页脚管理器带到键盘顶部,最终粉碎我的整个UI。确切的解决方案是什么?附:我已经一一删除了android:gravity="bottom"和android:layout_alignParentBottom="true"但是运气不好我没有得到想要的结果。谢谢 最佳答案 将android:windowSoftInputMode="adjustP

安卓 : change button text and background color

如何在按下按钮时使用xml更改文本和背景颜色?我可以改变文字颜色:我可以改变背景(在带有可绘制引用的选择器/项目中使用它):但是我怎样才能做到这两点呢?假设我想要:默认:黑色文字/白色背景按下:白色文字/蓝色背景编辑:回答我完全忘记了背景和文本颜色是分开管理的,所以我就是这样做的:在mybackgroundcolors.xml我管理背景,在filtersbuttoncolors.xml我管理文本颜色。在两个xml文件中,我管理状态(按下、选中、默认) 最佳答案 从API级别21开始,您可以使用:android:backgroundT

android - Button with image, ImageButton, and clickable ImageView的区别?

Buttonwithimage,ImageButton和clickableImageView有什么区别吗? 最佳答案 这可能只涵盖了部分差异,实际查看Android源代码树以了解发生了什么会有所帮助。ImageButtons具有推送状态,而可点击图像则没有。你也不能为ImageButton调用setText,你可以用一个普通的按钮。它们都来自View,但查看以下扩展链可能会有所帮助。java.lang.Object↳android.view.View↳android.widget.ImageView↳android.widget.I

android - 检索项目 : No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Borderless.Colored' 的父项时出错

我在androidstudio中启动新项目时收到这些错误。Error:(1)Errorretrievingparentforitem:Noresourcefoundthatmatchesthegivenname'android:TextAppearance.Material.Widget.Button.Borderless.Colored'.Error:(1)Errorretrievingparentforitem:Noresourcefoundthatmatchesthegivenname'android:TextAppearance.Material.Widget.Button.B

android - 我应该使用 android : process =":remote" in my receiver?

我有一个经常被调用的BroadcastReceiver,我注意到很多人都在使用android:process=":remote"在他们的接收器中。我的用于检查一些事情,如果条件匹配,则激活警报。我的问题是我应该使用上面在list中发布的行吗?如果是这样,这样做有什么好处? 最佳答案 通过使用android:process=":remote"定义您的接收器,您基本上可以在不同的进程(=VM)中运行您的接收器。对于典型的用例,您不需要在不同的进程中运行它,并且您想做的任何事情都可以在本地(在您的APK进程中)正常运行。使用android