我是新手kotlin,我尝试了几种使用以下代码的方法
val strAction = "Grid"
when(strAction){
strAction.contains("Grid")->println("position is 1")
}
Run Code Online (Sandbox Code Playgroud)
在上面的代码strAction.contains("Grid")中,这一行向我显示了一个不兼容类型的错误
今天我刚刚更新了我dependencies的material design
从1.0.0到1.1.0-alpha09
implementation 'com.google.android.material:material:1.1.0-alpha09'
Run Code Online (Sandbox Code Playgroud)
现在我遇到了奇怪的问题 com.google.android.material.textfield.TextInputLayout
这是我的代码
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/emailTextInputLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/_10sdp">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/emailTextInputEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/hint_enter_email"
android:imeOptions="actionNext"
android:inputType="textEmailAddress"/>
</com.google.android.material.textfield.TextInputLayout>
Run Code Online (Sandbox Code Playgroud)
更新依赖项后,我在我的 TextInputLayout
上面代码的输出
如果我使用implementation 'com.google.android.material:material:1.0.0'我会得到预期的结果
谁能帮我解决这个问题
如果需要更多信息,请告诉我。提前致谢。您的努力将不胜感激。
更新
我已经试过
app:boxBackgroundMode="none"了,我得到了这个
,
如果我使用
app:boxBackgroundMode="outline"然后得到这个

无需使用 boxBackgroundMode
你需要@style/Widget.Design.TextInputLayout在你的TextInputLayout
示例代码
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/emailTextInputLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/_10sdp"
style="@style/Widget.Design.TextInputLayout"
app:errorTextAppearance="@style/error_appearance"
android:textColorHint="@android:color/white">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:id="@+id/emailTextInputEditText"
android:layout_height="wrap_content"
android:backgroundTint="@android:color/white"
android:gravity="center"
android:hint="@string/hint_enter_email"
android:imeOptions="actionNext"
android:textColorHint="@android:color/white"
android:inputType="textEmailAddress"
android:textColor="@android:color/white"
android:textSize="@dimen/_15ssp"/>
</com.google.android.material.textfield.TextInputLayout>
Run Code Online (Sandbox Code Playgroud)
android android-layout material-design android-textinputlayout androidx
我该如何实现徒手剪裁Imageview.
使用下面的代码,我能够绘制手绘路径,并能够裁剪图像,但我面临一些其他问题
现在到目前为止我已经尝试过了
这是我的代码
使用画布裁剪图像的代码
public class SomeView extends View implements View.OnTouchListener {
private Paint paint;
int DIST = 2;
boolean flgPathDraw = true;
Point mfirstpoint = null;
boolean bfirstpoint = false;
Point mlastpoint = null;
Bitmap bitmap;
Context mContext;
public SomeView(Context c, Bitmap bitmap) {
super(c);
mContext = c;
this.bitmap = bitmap;
setFocusable(true);
setFocusableInTouchMode(true);
paint = new Paint(Paint.ANTI_ALIAS_FLAG);
paint.setStyle(Paint.Style.STROKE);
paint.setPathEffect(new DashPathEffect(new float[]{10, 20}, 0));
paint.setStrokeWidth(5);
paint.setColor(Color.RED);
paint.setStrokeJoin(Paint.Join.ROUND);
paint.setStrokeCap(Paint.Cap.ROUND);
this.setOnTouchListener(this);
points = new ArrayList<Point>();
bfirstpoint = false;
} …Run Code Online (Sandbox Code Playgroud) 我正在SingleChildScrollView使我的屏幕滚动,但是当我添加时,SingleChildScrollView我遇到了以下错误
RenderBox was not laid out: RenderRepaintBoundary#58c65 relayoutBoundary=up1 NEEDS-PAINT
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1681 pos 12: 'hasSize
Run Code Online (Sandbox Code Playgroud)
我的代码
class _RegisterPage extends State<RegisterApp> {
final _formKey = GlobalKey<FormState>();
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
theme:
ThemeData(primarySwatch: Colors.blue, brightness: Brightness.light),
darkTheme: ThemeData(brightness: Brightness.dark),
home: SafeArea(
child: Scaffold(
backgroundColor: Colors.white,
body: SingleChildScrollView(
child: Stack(
fit: StackFit.expand,
children: <Widget>[
Column(
children: <Widget>[
Column(
children: <Widget>[
Form(
key: _formKey,
child: new Theme(
data: ThemeData(
accentColor: Colors.purple,
primaryColor: Colors.blue, …Run Code Online (Sandbox Code Playgroud) 我正在按照这篇中等文章FloatingTitleTextInputField在我的反应本机项目中使用
下面是我的项目结构
这是我的代码HomeScreen.js
import React, {Component} from 'react';
import {Text, View, TextInput, StyleSheet} from 'react-native';
import FloatingTitleTextInputField from './customComponents/floating_title_text_input_field';
export default class HomeScreen extends Component {
render() {
return (
// <View style={{flex: 1, justifyContent: 'center', alignItems: 'center'}}>
// <Text>My First React App</Text>
// <TextInput style={{height: 40, borderColor: 'gray', borderWidth: 1}} />
// </View>
<View style={styles.container}>
<View style={styles.container}>
<Text style={styles.headerText}>Its Amazing</Text>
<FloatingTitleTextInputField
attrName="firstName"
title="First Name"
value={this.state.firstName}
updateMasterState={this._updateMasterState}
/>
<FloatingTitleTextInputField
attrName="lastName"
title="Last Name"
value={this.state.lastName}
updateMasterState={this._updateMasterState}
/>
</View> …Run Code Online (Sandbox Code Playgroud) 我已注册以下receiver内容未在Android Oreo中调用,但适用于较低版本的设备.
<receiver
android:name=".common.receiver.ConsultReceiver"
android:exported="false">
<intent-filter>
<action android:name="APP_STARTED" />
<action android:name="APP_STARTED_FROM_ORGANIC" />
</intent-filter>
</receiver>
Run Code Online (Sandbox Code Playgroud)
任何帮助,将不胜感激?
以下是我的依赖
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
Run Code Online (Sandbox Code Playgroud)
我的layout.xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff"
android:fitsSystemWindows="true">
<com.google.android.material.bottomappbar.BottomAppBar
android:id="@+id/bottomBar"
style="@style/Widget.MaterialComponents.BottomAppBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:backgroundTint="@color/colorPrimary"
app:fabAlignmentMode="center"
app:fabCradleMargin="10dp"
app:fabCradleVerticalOffset="4dp"
app:navigationIcon="@drawable/ic_drawer" >
</com.google.android.material.bottomappbar.BottomAppBar>
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_anchor="@id/bottomBar"
app:srcCompat="@drawable/ic_apps" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)
上面的代码对我来说很好
但是,当我更新dependencies的material design
implementation 'com.google.android.material:material:1.1.0-alpha01'
Run Code Online (Sandbox Code Playgroud)
我遇到以下错误:
java.lang.RuntimeException: Unable to start activity ComponentInfo{neel.com.bottomappbar/neel.com.bottomappbar.MainActivity}: android.view.InflateException: Binary XML file line #11: Binary XML file line #11: Error inflating class com.google.android.material.bottomappbar.BottomAppBar
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2485)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2545)
at android.app.ActivityThread.access$1100(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1396)
at android.os.Handler.dispatchMessage(Handler.java:102) …Run Code Online (Sandbox Code Playgroud) 我正在使用全屏通知我的代码在Oreo版本中和以下版本中工作但是当我运行时android-Q我遇到了异常
Use of fullScreenIntent requires the USE_FULL_SCREEN_INTENT permission
Run Code Online (Sandbox Code Playgroud)
我正在使用setFullScreenIntent()全屏通知
这是我的代码
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this, "123");
notificationBuilder.setAutoCancel(true)
.setColor(ContextCompat.getColor(this, R.color.colorAccent))
.setContentTitle(getString(R.string.app_name))
.setContentText("Test")
.setDefaults(Notification.DEFAULT_ALL)
.setWhen(System.currentTimeMillis())
.setFullScreenIntent(pendingIntent,true)
.setSmallIcon(R.drawable.ic_launcher_background)
.setAutoCancel(true);
mNotificationManager.notify(1000, notificationBuilder.build());
Run Code Online (Sandbox Code Playgroud) 我在我的演示项目中使用下面的路线
routes: <String, WidgetBuilder>{
'/HomePage': (BuildContext context) => HomePage()
},
Run Code Online (Sandbox Code Playgroud)
并尝试使用以下代码导航主屏幕
onPressed: () {
debugPrint("Hello button is clicked");
Navigator.of(context)
.pushReplacementNamed('/HomePage');
},
Run Code Online (Sandbox Code Playgroud)
但是当我点击按钮时,我得到了低于异常
???????? Exception caught by gesture ???????????????????????????????????????????????????????????????
The following assertion was thrown while handling a gesture:
Could not find a generator for route RouteSettings("/HomePage", null) in the _WidgetsAppState.
Generators for routes are searched for in the following order:
1. For the "/" route, the "home" property, if non-null, is used.
2. Otherwise, the "routes" table is used, if it …Run Code Online (Sandbox Code Playgroud) 在android中,我们app:behavior_overlapTop="64dp"用来实现这一目标
我希望在颤动中与上面的 GIF 相同的重叠内容
我的代码
class DetailsPage extends StatefulWidget {
@override
_DetailsPage createState() => _DetailsPage();
}
class _DetailsPage extends State<DetailsPage> {
@override
void initState() {
super.initState();
SystemChrome.setPreferredOrientations([
DeviceOrientation.portraitUp,
DeviceOrientation.portraitDown,
]);
_scrollController = ScrollController();
_scrollController.addListener(_scrollListener);
}
ScrollController _scrollController;
bool lastStatus = true;
_scrollListener() {
if (isShrink != lastStatus) {
setState(() {
lastStatus = isShrink;
});
}
}
bool get isShrink {
return _scrollController.hasClients &&
_scrollController.offset > (250 - kToolbarHeight);
}
@override
void dispose() {
_scrollController.removeListener(_scrollListener);
super.dispose();
}
@override
Widget …Run Code Online (Sandbox Code Playgroud) android ×10
dart ×3
flutter ×3
android-10.0 ×1
androidx ×1
bottombar ×1
components ×1
crop ×1
java ×1
kotlin ×1
react-native ×1
reactjs ×1