关于ionic之样式button-stable和ionic自定义样式的问题就给大家分享到这里,感谢你花时间阅读本站内容,更多关于(15)各种Button与排列OutlineButton,ButtonB
关于ionic之样式button-stable和ionic 自定义样式的问题就给大家分享到这里,感谢你花时间阅读本站内容,更多关于(15)各种Button 与排列 OutlineButton,ButtonBar,Expanded,RaisedButton,StadiumBorder,FlatButton.icon、Android Studio 之 用 Drawable resource file 美化 Button 样式、android – 在TableLayout中浮动Action Button错误的位置、android:button drawable for radiobutton 未在模拟器中加载等相关知识的信息别忘了在本站进行查找喔。
本文目录一览:- ionic之样式button-stable(ionic 自定义样式)
- (15)各种Button 与排列 OutlineButton,ButtonBar,Expanded,RaisedButton,StadiumBorder,FlatButton.icon
- Android Studio 之 用 Drawable resource file 美化 Button 样式
- android – 在TableLayout中浮动Action Button错误的位置
- android:button drawable for radiobutton 未在模拟器中加载
ionic之样式button-stable(ionic 自定义样式)
1、实例背景
ionic按钮button,设置样式为button-stable
2、实现源码
<!DOCTYPE html> <html> <head> <Meta charset="UTF-8"> <Meta name="viewport" content="initial-scale=1.0,maximum-scale=1.0,user-scalable=no" /> <title>ionic之样式button-stable</title> <link rel="stylesheet" href="../css/ionic.css" /> <script type="text/javascript" src="../js/ionic.bundle.js" ></script> <script> var app = angular.module("stableBtnApp",["ionic"]); app.controller("stableBtnController",function($scope){ $scope.stableBtn = "查询"; }); </script> </head> <body ng-app="stableBtnApp" ng-controller="stableBtnController"> <button> {{stableBtn}} </button> </body> </html>
3、实现结果
(15)各种Button 与排列 OutlineButton,ButtonBar,Expanded,RaisedButton,StadiumBorder,FlatButton.icon
效果
至于倒数第二行和倒数第一行的效果为啥一样。。可能是fluttersdk升级了。。之前的api不再生效。。算是留坑!
代码
import ''package:flutter/material.dart'';
class ButtonDemo extends StatelessWidget {
@override
Widget build(BuildContext context) {
final Widget _floatButtonDemo =
Row(mainAxisAlignment: MainAxisAlignment.center, children: [
FlatButton(
onPressed: () {},
child: Text("FlatButton"),
splashColor: Colors.grey,
textColor: Theme.of(context).accentColor,
color: Colors.black87,
),
FlatButton.icon(
icon: Icon(Icons.add),
onPressed: () {},
label: Text("FlatButton.icon"),
splashColor: Colors.grey,
textColor: Theme.of(context).accentColor,
color: Colors.black87,
)
]);
final Widget _raisedButtonDemo =
Row(mainAxisAlignment: MainAxisAlignment.center, children: [
Theme(
// data: ThemeData(),
data: Theme.of(context).copyWith(
buttonColor: Theme.of(context).accentColor,
buttonTheme: ButtonThemeData(
textTheme: ButtonTextTheme.primary,
// shape: BeveledRectangleBorder(borderRadius: BorderRadius.circular(5.0)),
shape: StadiumBorder(),
)),
child: RaisedButton(
onPressed: () {},
child: Text("RaisedButton"),
splashColor: Colors.grey,
textColor: Theme.of(context).accentColor,
// color: Colors.white,
// textTheme: ButtonTextTheme.primary,
elevation: 0.0,
)),
SizedBox(
width: 16.0,
),
RaisedButton.icon(
icon: Icon(Icons.add),
onPressed: () {},
label: Text("RaisedButton.icon"),
splashColor: Colors.grey,
textColor: Theme.of(context).accentColor,
elevation: 12.0,
)
]);
final Widget _outerLineButtonDemo =
Row(mainAxisAlignment: MainAxisAlignment.center, children: [
Theme(
// data: ThemeData(),
data: Theme.of(context).copyWith(
buttonColor: Theme.of(context).accentColor,
buttonTheme: ButtonThemeData(
textTheme: ButtonTextTheme.primary,
// shape: BeveledRectangleBorder(borderRadius: BorderRadius.circular(5.0)),
shape: StadiumBorder(),
)),
child: OutlineButton(
onPressed: () {},
child: Text("OutlineButton"),
splashColor: Colors.grey[100],
textColor: Colors.black,
borderSide: BorderSide(color: Colors.black),
highlightedBorderColor: Colors.grey,
// textTheme: ButtonTextTheme.primary,
)),
SizedBox(
width: 16.0,
),
OutlineButton.icon(
icon: Icon(Icons.add),
onPressed: () {},
label: Text("OutlineButton.icon"),
splashColor: Colors.grey,
textColor: Theme.of(context).accentColor,
)
]);
final Widget _widthOuterLineButton = Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
width: 200,
child: OutlineButton(
onPressed: () {},
child: Text("_widthOuterLineButton"),
splashColor: Colors.grey,
textColor: Colors.blue,
),
)
],
);
final Widget _expendOuterLineButton = Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Expanded(
child: OutlineButton(
onPressed: () {},
child: Text("_expendOuterLineButton"),
splashColor: Colors.grey,
textColor: Colors.blue,
),
)
],
);
final Widget _expend2OuterLineButton = Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Expanded(
flex: 1,
child: OutlineButton(
onPressed: () {},
child: Text("权重 for 1"),
splashColor: Colors.grey,
textColor: Colors.blue,
),
),
SizedBox(
width: 15,
),
Expanded(
//权重属性
flex: 2,
child: OutlineButton(
onPressed: () {},
child: Text("权重 for 2"),
splashColor: Colors.grey,
textColor: Colors.blue,
),
)
],
);
//一行并列行显示的按钮
final Widget _buttonBar = Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
ButtonBar(
children: [
OutlineButton(
onPressed: () {},
child: Text("ButtonBar"),
splashColor: Colors.grey,
textColor: Colors.blue,
),
OutlineButton(
onPressed: () {},
child: Text("ButtonBar"),
splashColor: Colors.grey,
textColor: Colors.blue,
),
],
)
],
);
//对刚才的并排中间添加边距
final Widget _buttonBarPaddingv = Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Theme(
data: Theme.of(context).copyWith(
buttonTheme: ButtonThemeData(
padding: EdgeInsets.symmetric(horizontal: 100.0))),
child: ButtonBar(
children: [
OutlineButton(
onPressed: () {},
child: Text("ButtonBar"),
splashColor: Colors.grey,
textColor: Colors.blue,
),
OutlineButton(
onPressed: () {},
child: Text("ButtonBar"),
splashColor: Colors.grey,
textColor: Colors.blue,
),
],
),
)
],
);
return Scaffold(
appBar: AppBar(
title: Text("button Demo"),
elevation: 0.0,
),
body: Container(
padding: EdgeInsets.all(16.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
_floatButtonDemo,
_raisedButtonDemo,
_outerLineButtonDemo,
_widthOuterLineButton,
_expendOuterLineButton,
_expend2OuterLineButton,
_buttonBar,
_buttonBarPaddingv
],
),
),
);
}
}
Android Studio 之 用 Drawable resource file 美化 Button 样式
shape
•新建 Drawable resource file
点击 app/src/main/res 找到 drawable 文件夹,右击->New->Drawable Resource File。
•常用属性
<gradient> : 设置渐变色
- startColor : 起始颜色
- endColor : 结束颜色
- centerColor : 中间颜色
- angle : 方向角度,等于 0 时,从左到右,然后逆时针方向转,当 angle = 90 度时从下往上
- type : 设置渐变的类型
<solid android:color = "xxx"> : 设置背景颜色
<stroke android:width = "xdp" android:color="xxx"> : 设置边框的粗细,以及边框颜色
<corners android:radius="10dp"...> : 设置圆角
•gradient
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <gradient android:endColor="#2196F3" android:startColor="#9C27B0" /> </shape>
•效果图
•solid
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <solid android:color="#2196F3" /> </shape>
•效果图
•stroke
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <solid android:color="#FCFCFC" /> <stroke android:width="1dp" android:color="#F44336" /> </shape>
•效果图
•corners
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <corners android:radius="10dp" /> <size android:width="100dp" android:height="200dp" /> <solid android:color="#2196F3" /> </shape>
•效果图
selector
•按下按钮时出现颜色变化
首先,新建一个 drawable resource file,根目录使用 selector ;
<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_pressed="false"> <shape> <corners android:radius="10dp" /> <solid android:color="#2196F3" /> </shape> </item> <item android:state_pressed="true"> <shape> <corners android:radius="10dp" /> <solid android:color="#9C27B0" /> </shape> </item> </selector>
•效果图
•参考资料
[1]:Android drawable resource file,圆角,渐变,自定义Switch
android – 在TableLayout中浮动Action Button错误的位置
>这是一张解释我problem的照片
>结果我想要get
在xml中:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" xmlns:app="http://schemas.android.com/apk/res-auto" > <TableLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:stretchColumns="*" > <TableRow android:id="@+id/tableRow1" android:layout_width="wrap_content" android:layout_height="wrap_content" > <android.support.design.widget.FloatingActionButton android:id="@+id/FloatingActionButton04" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/ic_launcher" app:elevation="4dp" app1:fabSize="mini" /> <android.support.design.widget.FloatingActionButton android:id="@+id/FloatingActionButton03" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/ic_launcher" app:elevation="4dp" /> <android.support.design.widget.FloatingActionButton android:id="@+id/FloatingActionButton02" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/ic_launcher" app:elevation="4dp" /> <android.support.design.widget.FloatingActionButton android:id="@+id/FloatingActionButton01" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/ic_launcher" app:elevation="4dp" /> <android.support.design.widget.FloatingActionButton android:id="@+id/myFAB" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/ic_launcher" app:elevation="4dp" /> </TableRow> <TableRow android:id="@+id/tableRow2" android:layout_width="wrap_content" android:layout_height="wrap_content" > <Button android:id="@+id/Button04" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button" /> <Button android:id="@+id/Button03" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button" /> <Button android:id="@+id/Button02" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button" /> <Button android:id="@+id/Button01" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button" /> <Button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button" /> </TableRow> <TableRow android:id="@+id/tableRow3" android:layout_width="wrap_content" android:layout_height="wrap_content" > <ProgressBar android:id="@+id/progressBar1"android:layout_width="wrap_content" android:layout_height="wrap_content" android:progress="60" /> </TableRow> <TableRow android:id="@+id/tableRow4" android:layout_width="wrap_content" android:layout_height="wrap_content" > <EditText android:id="@+id/editText1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:ems="10" android:text="Width OK" > <requestFocus /> </EditText> </TableRow> </TableLayout> </RelativeLayout>
解决方法
浮动操作按钮用于提升操作.每个屏幕仅建议使用一个浮动操作按钮来表示最常见的操作.因此,不要在一个原始中使用这么多的动作按钮.请改用普通按钮
android:button drawable for radiobutton 未在模拟器中加载
如何解决android:button drawable for radiobutton 未在模拟器中加载?
我想创建自定义 RadioButton,但遇到了问题。当我在 Android Studio 中预览我的工作时,一切似乎都很好,但在模拟器中我的 drawable 没有正确加载。 我错过了什么/做错了什么? 我的代码如下所示:
XML RadioGroup:
`<RadioGroup
android:id="@+id/ec_radiogroup"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="15dp"
android:layout_marginTop="10dp"
android:layout_marginEnd="15dp"
android:layout_marginBottom="10dp"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/ic_ec_switch">
<RadioButtonhttps://www.jb51.cc/tag/dio/" target="_blank">diobuttons"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:button="@drawable/it_radiobutton_sunrise"
android:padding="16dp"
android:text="Morgen" />
<RadioButtonhttps://www.jb51.cc/tag/dio/" target="_blank">diobuttons"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:button="@drawable/it_radiobutton_sun"
android:padding="16dp"
android:text="Mittag" />
<RadioButtonhttps://www.jb51.cc/tag/dio/" target="_blank">diobuttons"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:button="@drawable/it_radiobutton_sunrise"
android:padding="16dp"
android:text="Abend" />
</RadioGroup>`
XML drawable (android:button="@drawable/it_radiobutton_sunrise"):
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_checked="true"
android:drawable="@drawable/ic_radiobutton_sunrise_active"/>
<item
android:state_checkable="true"
android:drawable="@drawable/ic_radiobutton_sunrise_active"/>
<item
android:state_focused="true"
android:drawable="@drawable/ic_radiobutton_sunrise_active"/>
<item
android:state_activated="true"
android:drawable="@drawable/ic_radiobutton_sunrise_active"/>
<item
android:state_pressed="true"
android:drawable="@drawable/ic_radiobutton_sunrise_active"/>
<item
android:state_selected="true"
android:drawable="@drawable/ic_radiobutton_sunrise_active"/>
<item
android:state_checked="false"
android:drawable="@drawable/ic_radiobutton_sunrise_inactive" />
<item
android:state_checkable="false"
android:drawable="@drawable/ic_radiobutton_sunrise_inactive" />
<item
android:state_focused="false"
android:drawable="@drawable/ic_radiobutton_sunrise_inactive" />
<item
android:state_activated="false"
android:drawable="@drawable/ic_radiobutton_sunrise_inactive" />
<item
android:state_pressed="false"
android:drawable="@drawable/ic_radiobutton_sunrise_inactive" />
<item
android:state_selected="false"
android:drawable="@drawable/ic_radiobutton_sunrise_inactive" />
</selector>
它应该是什么样子:
解决方法
我在一些较旧的 android 版本上遇到了类似的问题,请尝试将其添加到模块 build.gradle 中。
android {
defaultConfig {
vectorDrawables.useSupportLibrary = true
}}
我们今天的关于ionic之样式button-stable和ionic 自定义样式的分享就到这里,谢谢您的阅读,如果想了解更多关于(15)各种Button 与排列 OutlineButton,ButtonBar,Expanded,RaisedButton,StadiumBorder,FlatButton.icon、Android Studio 之 用 Drawable resource file 美化 Button 样式、android – 在TableLayout中浮动Action Button错误的位置、android:button drawable for radiobutton 未在模拟器中加载的相关信息,可以在本站进行搜索。
本文标签: