A:
Bitmap immutableBmp= BitmapFactory.decodeResource(getApplicationContext().getResources(),R.drawable.sample);
mutableBitmap=immutableBmp.copy(Bitmap.Config.ARGB_8888, true);
Run Code Online (Sandbox Code Playgroud)
B:
Bitmap immutableBmp= BitmapFactory.decodeFile(filePath);
mutableBitmap=immutableBmp.copy(Bitmap.Config.ARGB_8888, true);
Run Code Online (Sandbox Code Playgroud)
C:
BitmapFactory.Options options = new BitmapFactory.Options();
options.inMutable=true;
myBitmap=BitmapFactory.decodeFile(filePath,options);
Run Code Online (Sandbox Code Playgroud)
A作品,但B和C不.我试图将不可变位图转换为可变位图.它适用于资源图像,但不适用于文件图像.有什么问题?
根据Firebase网站,我使用此代码创建一个新用户:
firebase.auth().createUserWithEmailAndPassword(email, password).catch(function(error) {});
Run Code Online (Sandbox Code Playgroud)
如何在创建新用户时向Auth添加显示名称和照片网址?
此链接显示从Auth中的身份提供程序返回的受支持的用户数据.
我正在尝试实现用户可调整大小的edittext视图.当用户拖动视图边缘时,可以调整大小.
这是我用于edittext的onTouchListener.我只实现了左边缘的调整大小.我的想法是,当用户的触摸事件x等于视图的左边距(这意味着用户触摸左边缘)时,视图的宽度和左边距将变化.
protected View.OnTouchListener etTouchListener=new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent event) {
float x=event.getX();
float y=event.getY();
ViewGroup.MarginLayoutParams params=(ViewGroup.MarginLayoutParams)view.getLayoutParams();
int top=params.topMargin;
int bottom=params.bottomMargin;
int left=params.leftMargin;
int right=params.rightMargin;
if(x==left){
switch (event.getAction()){
case MotionEvent.ACTION_DOWN:
resize_start(x,y);
Log.e("left edge","clicked");
break;
case MotionEvent.ACTION_MOVE:
resize_move(x,y);
params.leftMargin=(int)nX;
params.width=(int)(editNoteViewParent.getWidth()-nX-params.rightMargin);
view.setLayoutParams(params);
Log.e("left edge","dragged");
break;
case MotionEvent.ACTION_UP:
break;
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的resizeStart():
private void resize_start(float x,float y){
nX = x;
nY = y;
}
Run Code Online (Sandbox Code Playgroud)
而我的resizeMove():(当用户拖动边缘时)
private void resize_move(float x, float y){
float dx = Math.abs(x - nX);
float dy …Run Code Online (Sandbox Code Playgroud) 我正在使用绑定适配器来防止 2 路绑定的编辑文本的不断文本更新。
@BindingAdapter("binding")
public static void bindEditText(EditText editText, final String str) {
if ((!editText.getText().toString().equals(str)) && !editText.getText().equals("")) {
editText.setText(str);
}
}
Run Code Online (Sandbox Code Playgroud)
它适用于带有整数默认文本的编辑文本。但是当涉及到使用浮动默认文本编辑文本时。例如:70.0,当我输入第一个数字时,编辑文本会刷新并变为例如:8.0。然后光标向左移动,后面的所有数字都将被添加到前面。例如:198.0
试过这个,但不起作用。
@BindingAdapter("binding")
public static void bindEditText(EditText editText, final String str) {
if ((!(editText.getText().toString()+".0").equals(str)) && !editText.getText().equals("")) {
editText.setText(str);
}
}
Run Code Online (Sandbox Code Playgroud)
有什么解决办法吗?
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="com.now.sexyfacechanger.Activity_PhotoOrGallery">
<include layout="@layout/content_activity__photo_or_gallery" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:orientation="horizontal">
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab_camera"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:src="@android:drawable/ic_menu_camera"
android:layout_weight="1"/>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab_gallery"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:src="@android:drawable/ic_menu_gallery"
android:layout_weight="1"/>
</LinearLayout>
</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)
这是android studio设计中的视图,显示的线性布局与父级匹配:
但是输出:
线性布局与父布局不匹配,或者我怀疑应用于两个浮动按钮的 layout_weight 在协调器布局中不起作用。
android android-linearlayout android-layout-weight android-coordinatorlayout android-layoutparams
android ×4
ios ×2
swift ×2
bitmap ×1
data-binding ×1
firebase ×1
immutability ×1
keyboard ×1
layoutparams ×1
mutable ×1
ontouch ×1
resize ×1
uitextview ×1
view ×1