我正在为 Android 制作游戏,但在进行下一次更新时遇到了问题。游戏设置为从 API 19 开始工作。我正在使用 ObjectAnimator 类为教程中指向按钮的小弹跳箭头设置动画。没有什么花哨。
代码:
//Animate minestone clicker button arrow
b1_animator = ObjectAnimator.ofFloat(button_minestone_pointer,"translationX",0,-100);
b1_animator.setDuration(500);
b1_animator.setRepeatMode(ValueAnimator.REVERSE);
b1_animator.setRepeatCount(Animation.INFINITE);
b1_animator.start();
Run Code Online (Sandbox Code Playgroud)
问题是,动画在 Android Studio (API 19 - API 27) 和所有更新的 API 提供的所有虚拟设备上都很流畅,但在我的手机 (Sharp SH-01G) 上,它运行的是 Android 4.4、自动滚动或这些箭头从一个位置跳转到另一个创建模糊图像。还没有机会在另一个 API21 之前的设备上检查它。感觉它不尊重“.setDuration();” 少量。卷轴会立即跳到所需的位置,但一点也不流畅。
这是滚动条代码:
ObjectAnimator.ofInt(scroller_clickers, "scrollX", 800).setDuration(777).start();
Run Code Online (Sandbox Code Playgroud)
所以问题是,是什么导致了这种行为?我也尝试使用 view.animate() 代替,但它也没有帮助。线索是,当我尝试查找“getAnimatedFraction();”时 值,模拟器显示各种分数 - 0.0 和 1 之间的平滑过渡。我的手机总是以某种随机顺序显示 0.0 或 1.0(将其填充到 TextView 中并使用 Runnable 刷新)。分配“AccelerateDecelerateInterpolator()”也不起作用。我不想向公众展示一个有缺陷的游戏:(
有任何想法吗?
如何隐藏图像但仍然让它在堆栈视图中占据空间?
目前我设置了image.isHidden = false,我的堆栈视图元素重新排列并挤压了图像空间。有没有办法让图像在隐藏时仍然占据空间?
我希望高质量的图像显示ImageView并上传到服务器。我已经在 Internet、StackOverflow 和 GitHub 上搜索过,但找不到答案,也许有人知道如何解决?
protected void onActivityResult(int requestCode, int resultCode, Intent imageReturnedIntent) { //work android
super.onActivityResult(requestCode, resultCode, imageReturnedIntent);
imageReturnedIntent.putExtra(MediaStore.EXTRA_OUTPUT, uri);//try
if (resultCode == RESULT_OK ) {// work every android than need click OK
//working
Uri selectedImage = imageReturnedIntent.getData();//convert to for bitmap that can send
Bundle extras = imageReturnedIntent.getExtras();//finish converting and copy the image
bitmap = extras.getParcelable("data");//receive image to bitmap
imageView.setImageBitmap(bitmap);
Run Code Online (Sandbox Code Playgroud)
onCreate:
btnCamera.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
//intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri); …Run Code Online (Sandbox Code Playgroud) 我遇到了麻烦imageView.setColorFilter()。在我的应用程序中,我有深色模式(黑色背景、白色文本)和浅色模式(白色背景、黑色文本)。
针对API 21+,我使用由Android Studio生成矢量资源的图标是白色的,在默认情况下android:tint="#FFFFFF"并android:fillColor="#FF000000"在XML文件中。
根据材料设计,图标具有适用于不同状态的特定 alpha。我正在使用状态Active + Unfocused,其中黑色图标 = #8A000000和白色图标 = #B3FFFFFF。
在黑暗模式下,图标将在黑色背景上显示为灰色,这正是应用了 alpha 时应有的样子。但是,在浅色模式下,无论上面的 alpha 如何,图标都是 100% 黑色。我正在使用imageView.setColorFilter()with default应用颜色PorterDuff.Mode.SRC_ATOP。
这里发生了什么,我该如何解决?谢谢你。
fun tap(view: View) {
val img = view
}
Run Code Online (Sandbox Code Playgroud)
我希望这个变量 img 是一个图像视图,但不知道如何将视图转换为图像视图。
嗨我想在我的视图中显示存储在SD卡中的3或4个图像,图像的大小约为1-2 MB.我的问题是当我在imageview中使用图像然后它抛出内存异常我在将图像解码为位图时创建了位和传递选项
02-26 13:16:54.946: ERROR/dalvikvm-heap(23410): 15980544-byte external allocation too large for this process.
02-26 13:16:54.946: ERROR/dalvikvm(23410): Out of memory: Heap Size=3407KB, Allocated=2801KB, Bitmap Size=15630KB, Limit=21884KB
02-26 13:16:54.946: ERROR/dalvikvm(23410): Trim info: Footprint=3463KB, Allowed Footprint=3655KB, Trimmed=248KB
02-26 13:16:54.946: ERROR/GraphicsJNI(23410): VM won't let us allocate 15980544 bytes
02-26 13:16:54.986: ERROR/AndroidRuntime(23410): FATAL EXCEPTION: main
02-26 13:16:54.986: ERROR/AndroidRuntime(23410): java.lang.OutOfMemoryError: bitmap size exceeds VM budget
02-26 13:16:54.986: ERROR/AndroidRuntime(23410): at android.graphics.BitmapFactory.nativeDecodeFile(Native Method)
02-26 13:16:54.986: ERROR/AndroidRuntime(23410): at android.graphics.BitmapFactory.decodeFile(BitmapFactory.java:325)
Run Code Online (Sandbox Code Playgroud)
任何机构都可以提前帮助我解决我的问题
我在按钮单击时使用了以下方法来显示带有图像列表的对话框.如果我从图像中删除setOnclickListener,该对话框正常工作.但是如果我将setOnclickListener用于图像,应用程序将会停止运行.
private void showFrame(){
frameDialog = new Dialog(CameraActivity.this);
frameDialog.setContentView(R.layout.frame_selection);
frameDialog.setTitle("Select a frame");
ImageView thumb1 = (ImageView) findViewById(R.id.thumbView1);
ImageView thumb2 = (ImageView) findViewById(R.id.thumbView2);
ImageView thumb3 = (ImageView) findViewById(R.id.thumbView3);
frameDialog.show();
thumb1.setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(getApplicationContext(), "to this is okay!", Toast.LENGTH_LONG).show();
frameDialog.dismiss();
}
}
);
thumb2.setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(getApplicationContext(), "to this is okay!", Toast.LENGTH_LONG).show();
frameDialog.dismiss();
}
}
);
thumb3.setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View …Run Code Online (Sandbox Code Playgroud) 我有一个基于本教程的项目,其中用户旋转一个轮子,一个数字的值int days根据轮子的当前位置而改变,现在我想ImageView circle根据这个数字的值显示或隐藏另一个图像,但是它抛出NullPointerException
这是我的onTouch事,抱歉我的英语不好
@Override
public boolean onTouch(View v, MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
// reset the touched quadrants
for (int i = 0; i < quadrantTouched.length; i++) {
quadrantTouched[i] = false;
}
allowRotating = false;
startAngle = getAngle(event.getX(), event.getY());
break;
case MotionEvent.ACTION_MOVE:
double currentAngle = getAngle(event.getX(), event.getY());
rotateDialer((float) (startAngle - currentAngle));
startAngle = currentAngle;
days = ((int) currentAngle / 12) + 1;
String test = Integer.toString(days);
tvnumber.setText(test); …Run Code Online (Sandbox Code Playgroud) 我使用mvvmcross并且无法绑定到图像URL.错误:未注册IMvxImageHelper - 必须先提供图像帮助才能使用MvxImageView
<Mvx.MvxImageView
p1:id="@+id/imgArticle"
p1:layout_width="49dp"
p1:layout_height="49dp"
p1:layout_marginLeft="5dp"
p1:layout_marginTop="5dp"
local:MvxBind="ImageUrl Image, Converter = Image"
p1:layout_marginBottom="5dp"
p1:background="#ffff0000" />
Run Code Online (Sandbox Code Playgroud)
我的型号:
public Guid Id { get; set; }
public string Name { get; set; }
public string Image { get; set; }
public decimal Price { get; set; }
Run Code Online (Sandbox Code Playgroud) 我在cardview中使用带有回收器的imageview.我还为不同的屏幕尺寸创建了文件夹.它适用于小屏幕手机和平板电脑,但手机屏幕超过5.5英寸存在缩放问题
代码如下:
cardview.xml(420dp)
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.CardView
android:id="@+id/card_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_margin="15dp"
android:elevation="3dp"
card_view:cardCornerRadius="5dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/thumbnail"
android:layout_width="match_parent"
android:layout_height="@dimen/album_cover_height"
android:background="?attr/selectableItemBackgroundBorderless"
android:clickable="true"
android:scaleType="fitXY"
android:src="@drawable/ritu"/>
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/thumbnail"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:paddingTop="10dp"
android:textColor="#4c4c4c"
android:textSize="15dp"
android:textAlignment="center"/>
</RelativeLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
cardview.xml(600dp)
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.CardView
android:id="@+id/card_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_margin="15dp"
android:elevation="3dp"
card_view:cardCornerRadius="5dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/thumbnail"
android:layout_width="match_parent"
android:layout_height="@dimen/album_cover_height"
android:background="?attr/selectableItemBackgroundBorderless"
android:clickable="true"
android:scaleType="fitXY"
android:src="@drawable/ritu"/>
<!---->
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/thumbnail"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:paddingTop="10dp"
android:textColor="#4c4c4c"
android:textSize="15dp"
android:textAlignment="center"/>
</RelativeLayout>
</android.support.v7.widget.CardView> …Run Code Online (Sandbox Code Playgroud)