更新 :我通过使用在这个答案中描述的方法解决了这个问题 我有点卡住这个问题,我觉得应该是非常简单的。 所以我的应用程序下载一个图像,并呈现在一个ImageView,一个RelativeLayout的子元素的位图。 我希望ImageView适合父宽度,并调整它的大小来保持宽高比。 这是我的XML: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <RelativeLayout android:id="@+id/banner" android:layout_width="fill_parent" android:layout_height="wrap_content"></RelativeLayout> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/hello" /> </LinearLayout> 和代码: public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); RelativeLayout banner = (RelativeLayout) findViewById(R.id.banner); ImageView imgV = new ImageView(this); imgV.setScaleType(ImageView.ScaleType.CENTER_CROP); // I tried all the scale types : CENTER_INSIDE : same […]
我试图在我的应用程序中创build一个简单的ImageViewanimation,并且我希望它从屏幕底部滑入,并进入静止位置,顶部50px的视图离开屏幕的顶部(例如最终位置的ImageView应该在-50px在X)。 我试图使用AbsoluteLayout来做到这一点,但是这实际上切断了ImageView的顶部50px,使得顶部的50px永远不会被渲染。 我需要让ImageView的顶部50像素可见/呈现animation,然后稍微离开屏幕稍微rest一下。 我希望我已经解释得很好。 这是我目前使用的布局和幻灯片animation(目前不会呈现ImageView的顶部50px): 布局: <?xml version="1.0" encoding="utf-8"?> <AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_height="fill_parent" android:layout_width="fill_parent" android:id="@+id/QuickPlayClipLayout"> <ImageView android:id="@+id/Clip" android:background="@drawable/clip" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_y="-50dp"> </ImageView> </AbsoluteLayout> animation: <?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android"> <translate android:fromYDelta="100%p" android:toYDelta="0" android:duration="1000"/> <alpha android:fromAlpha="0.0" android:toAlpha="1.0" android:duration="1000" /> </set> 提前致谢。
我想在ImageView中使用Url设置图像,例如我有这个url http://www.google.iq/imgres?hl=en&biw=1366&bih=667&tbm=isch&tbnid=HjzjsaANDXVR9M:&imgrefurl=http://www.vectortemplates.com/raster-batman.php&docid=FxbVmggVf–0dM&imgurl=http:/ /www.vectortemplates.com/raster/batman-logo-big.gif&w=2072&h=1225&ei=Zeo_UoSWIMaR0AXl_YHIBg&zoom=1 但是没有选项来设置url
我想设置一个ImageView的LayoutParams ,但似乎找不到正确的方法来做到这一点。 我只能在各种ViewGroups的API中find文档,而不是ImageView 。 然而ImageView似乎有这个function。 此代码不起作用… myImageView.setLayoutParams(new ImageView.LayoutParams(30,30)); 我该怎么做?
我目前正在为Android(我的第一个应用程序)开发一个应用程序,让用户看到地铁地图,并能够缩放和拖动。 我目前正在修改在Android的第三版中find的代码,并得到了缩放和拖动工作。 我使用matrix作为我的布局规模。 但是我现在有三个问题: 我尝试了很多事情来限制拖动参数,但我似乎无法阻止它被拖离父视图(实际上可以从视图中消失)。 我已经尝试在XML文件中设置布局参数,它只是不起作用。 我可以缩放变细,但我又遇到了麻烦,限制了变焦的数量。 我试图通过设置max_zoom和min_zoom来限制缩放值(我将在后面发布我的代码) 我也试图在图像上绘制一个坐标,以便人们可以点击某些部分(这样做的关键是让用户点击地图上的一个站点并查看关于它的信息) 我有一种感觉,我有麻烦,因为我正在使用matrix规模。 这是我现在的代码: Touch.java package org.example.touch; import android.app.Activity; import android.graphics.Bitmap; import android.graphics.Matrix; import android.graphics.PointF; import android.os.Bundle; import android.util.FloatMath; import android.util.Log; import android.view.MotionEvent; import android.view.View; import android.view.View.OnTouchListener; import android.widget.GridView; import android.widget.ImageView; public class Touch extends Activity implements OnTouchListener { private static final String TAG = "Touch"; private static […]
好的,我一直在引用代码: 在网格布局上进行手势检测 但只是不能得到它的工作。 在我的主要活动中,我定义了一个简单的图像。 我想要检测图像上的一个闪光。 这是我的代码如下。 底部的onclick方法是空的。 是因为这个吗? 我把它留空,因为在其他代码示例中,它不是我想要的。 我只是想要一个简单的敬酒popup说扔或右扔。 public class GestureRightLeft extends Activity implements OnClickListener { ImageView peek; private static final int SWIPE_MIN_DISTANCE = 120; private static final int SWIPE_MAX_OFF_PATH = 250; private static final int SWIPE_THRESHOLD_VELOCITY = 200; private GestureDetector gestureDetector; View.OnTouchListener gestureListener; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); peek […]
我正在build设一个幻灯片,有一些麻烦。 我已经在xml中创build了2个淡入和淡出的animation: fadein.xml <?xml version="1.0" encoding="UTF-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android"> <alpha android:fromAlpha="0.0" android:toAlpha="1.0" android:interpolator="@android:anim/accelerate_interpolator" android:duration="2000"/> </set> fadeout.xml <?xml version="1.0" encoding="UTF-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android"> <alpha android:fromAlpha="1.0" android:toAlpha="0.0" android:interpolator="@android:anim/accelerate_interpolator" android:duration="2000"/> </set> 需要做的是从ImageView中使用淡入淡出效果改变图像,所以当前显示的图像会淡出,而另一个淡入淡出。考虑到我已经设置了一个图像,我可以淡入淡出此图像问题,与此: Animation fadeInAnimation = AnimationUtils.loadAnimation(this, R.anim.your_fade_in_anim); imageView.startAnimation(fadeoutAnim); 但是,然后,我设置下一个图像显示: imageView.setImageBitmap(secondImage); 它只是显示在imageView,当我设置animation隐藏图像,淡入淡出…有什么办法解决,我的意思是,当我做imageView.setImageBitmap(secondImage); 命令,图像不会立即显示出来,只有在执行淡入淡出animation的时候?
需要为图像视图设置色调…我使用以下方法: imageView.setColorFilter(R.color.blue,android.graphics.PorterDuff.Mode.MULTIPLY); 但它不会改变…
我尝试在图像视图中显示一个GIF图像作为加载占位符 – 使用Glide库 : Glide.with(context) .load(ImageUrl()) .placeholder(R.drawable.loading2) .asGif() .crossFade() .into(image); 我试图展示这个文件 loading2.gif 但得到这个错误: 错误:(54,86)错误:无法find符号方法asGif() 我怎样才能显示GIF文件与glide在imageView?
我试图获得图像视图中显示的图像的实际大小。 其实我的图像比屏幕更大,imageview正在调整图像来显示它。 我正在寻找这个新的尺寸。 我试图覆盖自定义视图中ImageView的onDraw方法,但我没有得到正确的高度和宽度… public class LandImageView extends ImageView { public LandImageView( Context context ) { super( context ); } public LandImageView(Context context, AttributeSet attrs) { super(context, attrs); } public LandImageView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } @Override protected void onDraw( Canvas canvas ) { super.onDraw( canvas ); int test = […]