Tag: android imageview

Android + Java从服务器上的URL获取图像并作为字符串传递给客户端:Base64解码和编码无法正常工作

在Java服务器中,我从外部服务URL获取图像,如: InputStream in = new java.net.URL(imageWebServiceURL).openStream(); String resultToCleint = org.apache.commons.codec.binary.Base64.encodeBase64URLSafeString(IOUtils.toByteArray(in)); 然后在Android上我解析它: byte[] imageAsBytes = Base64.decode(resultToCleint.getBytes(), Base64.DEFAULT); imageView.setImageBitmap(BitmapFactory.decodeByteArray(imageAsBytes, 0, imageAsBytes.length)); 结果:图像未显示,不是服务器上或客户端上的错误/exception。 这里有什么问题? 编辑:在Android上我使用类android.util.Base64 谢谢,

如何使用Android中的java在Click上放大/缩小imageView?

我已经按照本教程放大了触摸imageview ,但我有一个活动,有15个图像,当我点击任何一个图像时,它将打开新的活动,并将放大新活动上点击的图像所以我的问题是 如何将单击的图像src传递给nextActivity,以便我的单个方法适用于放大所有图像。 在我点击它的新活动(放大)时,我如何再次缩小该图像。 我跟着这个: 放大 它成功放大了一个imageview但我不知道如何编写缩小代码。有人请帮助我完成这项任务。 任何教程将不胜感激,但链接必须包含与此URL中相同的代码,并进行一些缩小更改

Android – 在ImageView中使用大图像或不同大小的图像

我有一个“仪表板”菜单,适用于Android。 它有八个ImageViews,就像我需要它一样工作。 ——————- | | | | 1 | 2 | ——————- ——————- | | | | 3 | 4 | ——————- ——————- | | | | 5 | 6 | ——————- ——————- | | | | 7 | 8 | ——————- 我以非常高的分辨率使用8个不同的图像,使它们在任何地方看起来都很好。 我不在任何不同的dpi文件夹中包含它们。 我只有一个大的分辨率,所有屏幕尺寸都可以。 这是不好的做法吗? 我应该为每个人准备不同尺寸的图像吗?

为什么X的值不会一直到布局的边缘

palette2 drawable用作背景: esquare drawable(使用@dimenresize并用作拇指): XML: Java的: llColors = (RelativeLayout) findViewById(R.id.rlColorSpect); llColors.setOnTouchListener(llTouch); bitmap = BitmapFactory.decodeResource(this.getResources(), R.drawable.palette2); llColors.setBackground(getResources().getDrawable(R.drawable.palette2)); w = bitmap.getWidth(); h = bitmap.getHeight(); Log.i(“PALETTE WIDTH”, “width” +w); Log.i(“PALETTE HEIGHT”, “height” +h); observer = llColors.getViewTreeObserver(); observer.addOnGlobalLayoutListener(new OnGlobalLayoutListener() { @Override public void onGlobalLayout() { width = llColors.getWidth(); height = llColors.getHeight(); Log.i(“LAYOUT WIDTH”, “width” +width); Log.i(“LAYOUT HEIGHT”, “height” +height); […]

数组适配器从Res文件夹加载图像(Android应用程序)

我是一个Android新手。 我试图通过数组适配器将我的res / Drawable文件夹中的一堆图像加载到Gridview中。 不幸的是,我每次尝试使用gridView查看活动时都会崩溃。 我想知道如何设置我在res文件夹中的图像的imageResource以显示在Gridview中。 这是我的代码: Smile.class public class Smiley extends Activity { GridView gridView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.smile); gridView = (GridView) findViewById(R.id.gridView1); String planets[] = this.getResources().getStringArray(R.array.imageme); ArrayAdapteradapter = new ArrayAdapter (this,R.layout.grid_view_row,R.id.imageGrid , planets); gridView.setAdapter(adapter); } } Smile.xml grid_view_row.xml(Gridview的自定义布局) 我的字符串数组(xml) @drawable/a @drawable/b @drawable/c @drawable/d logcat的 09-04 16:48:40.561: E/ArrayAdapter(25938): You must […]

从galery中选择图像并在imageview中显示

对不起写,但我有一个大问题.. 我6个小时寻找结果但是..没有:( 我需要在手机中打开我的galery并选择在imageview上打开活动的一张图片..没有什么难…但我有代码和模拟器(genymotion)中的代码运行完美..但在真正的手机小米Mi4什么都没有。 打开galery选择项目,什么也没有。 我没有更多的手机:( 我尝试下载这个主题的一些例子,每一个都是一样的…当我选择项目应用程序什么都不做时,galery打开.. 请问你有类似的问题吗? 你有一些项目与galery选择图像和imageview显示? 如果是的话请分享你的代码并上传我的地方.apk试试,因为我…… :(:’( 我的朋友 apply plugin: ‘com.android.application’ android { compileSdkVersion 25 buildToolsVersion “24.0.2” defaultConfig { applicationId “paradox.galopshop” minSdkVersion 19 targetSdkVersion 25 versionCode 1 versionName “1.0” testInstrumentationRunner “android.support.test.runner.AndroidJUnitRunner” } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile(‘proguard-android.txt’), ‘proguard-rules.pro’ } } } dependencies { compile fileTree(dir: ‘libs’, include: [‘*.jar’]) androidTestCompile(‘com.android.support.test.espresso:espresso-core:2.2.2’, […]

获取ImageView的图像并将其发送到使用Intent的活动

我的应用程序中有许多产品网格。 当用户选择网格中的一个项目时,我将开始一个新的活动作为DIALOG框并显示项目的名称,数量和图像。 但是我无法动态发送图像源。 这是我的代码 gridView.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView parent, View v,int position, long id) { //Toast.makeText(getApplicationContext(),((TextView) v.findViewById(R.id.grid_item_label)).getText(), Toast.LENGTH_SHORT).show(); Intent item_intent = new Intent(MainActivity.this, Item.class); item_intent.putExtra(“name”,((TextView) v.findViewById(R.id.grid_item_label)).getText()); item_intent.putExtra(“quantity”,((TextView) v.findViewById(R.id.grid_item_quantity)).getText()); //my problem is here*************************************************** ImageView my_image = findViewById(R.id.grid_item_image).getDrawable(); item_intent.putExtra(“image”,my_image.getXXXXX()); //********************************************************************* MainActivity.this.startActivity(item_intent); } }); 我应该使用什么来从ImageView获取图像源?