标签: android-imageview

如何在Android ImageView中设置图像

当我按下应用程序上的按钮时,我需要显示图像.

我正在尝试:

ImageView imageView = (ImageView) findViewById(R.id.imageView2);
imageView.setImageDrawable(R.drawable.loading);
Run Code Online (Sandbox Code Playgroud)

但它显示错误.

有人可以帮帮我吗?谢谢.

android android-imageview

0
推荐指数
1
解决办法
1147
查看次数

如何获取从Bitmap形成的ImageView的初始URL

最初我使用a从外部URL创建了一个位图bitmapFactory.然后我将位图放在图像视图中,如:

 ImageView mim = (ImageView) findViewById(R.id.moviepix);
 String mi = "http://xxxxxxx.com/"+ result.movie_pix;
Bitmap bitmap = BitmapFactory.decodeStream((InputStream)new    URL(mi).getContent());
mim.setImageBitmap(bitmap);
Run Code Online (Sandbox Code Playgroud)

现在我需要对网址进行反向工程ImageView.

所有帮助表示赞赏.

android android-imageview

0
推荐指数
1
解决办法
2158
查看次数

如何在不改变ImageView宽度的情况下设置图像的宽度(在ImageView中)?

我想要做的是在不影响ImageView宽度的情况下更改ImageView中图像的宽度.

    ----------------------------------------------------------------
    |                                                              |
    |                                                              |
    |         ----------------------------------------------       |
    |         |                                            |       |
    |         |                                            |       |
    |         |    this is the image( change its width)    |       |
    |         |                                            |       |
    |         ----------------------------------------------       |
    |                                                              |
    |      this is imageView the width mustnt change               |
    ----------------------------------------------------------------
Run Code Online (Sandbox Code Playgroud)

我怎样才能做到这一点?请帮忙?

java android imageview android-imageview

0
推荐指数
1
解决办法
176
查看次数

splashscreen imageview不显示图像

大家好我有这个启动画面的布局main.xml,其中包含一个imageview,这里是main.xml文件

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/LinearLayout2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ImageView
    android:id="@+id/imageView1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:src="@drawable/slide11" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

这是我的splashscreen.class文件

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
 try {  
           new Handler().postDelayed(new Runnable() {
            public void run() 
            Intent intent = new Intent(getApplicationContext(),content_activity.class);
            startActivity(intent);
            Main.this.finish();   }  }, 5000);
            } catch(Exception e){}
}
 @Override
public void onBackPressed() {

        super.onBackPressed();
} }
Run Code Online (Sandbox Code Playgroud)

当我尝试在我的模拟器中运行这一切都工作正常,但当我尝试通过调试模式在设备中运行它我没有得到imageView中指定的图像,但我得到一个指定时间的白色屏幕.任何帮助将非常感激.

//编辑:我仔细检查了res/drawable文件夹,我主要尝试使用png,并且还使用.gif在设备中没有工作.(设备micromax a110)

android splash-screen android-imageview

0
推荐指数
2
解决办法
3807
查看次数

如何从相机中捕捉图像,碎片,

我是Android新手,我已经做了很多培训,但图像没有从相机加载.以下是我从相机或图库中捕获图像的代码:

    public void showDiloag(){
    Dialog dialog = new Dialog(getActivity());
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setTitle("Choose Image Source");
    builder.setItems(new CharSequence[] { "Gallery", "Camera" },
            new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog,
                        int which) {
                    switch (which) {
                    case 0:
                        Intent intent = new Intent(
                                Intent.ACTION_GET_CONTENT);
                        intent.setType("image/*");

                        Intent chooser = Intent
                                .createChooser(
                                        intent,
                                        "Choose a Picture");
                        getAcitivity.startActivityForResult(
                                chooser,
                                ACTION_REQUEST_GALLERY);

                        break;

                    case 1:
                        Intent cameraIntent = new Intent(
                                android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
                        startActivityForResult(
                                cameraIntent,
                                ACTION_REQUEST_CAMERA);

                        break;

                    default:
                        break;
                    }
                }
            });

    builder.show();
    dialog.dismiss();
}
Run Code Online (Sandbox Code Playgroud)

并显示该照片: …

android android-image android-camera android-imageview

0
推荐指数
1
解决办法
5539
查看次数

它是一个用于加载图像并获得http状态的Android库吗?

我有一个应用程序,我使用库Ion(https://github.com/koush/ion).问题是我意识到我需要在加载失败时获得http状态.

我有一个休息服务,根据出了什么问题返回不同的状态,并且需要在应用程序中有不同的逻辑.

这是休息服务的代码:

@GET
@Path("/damages/image/get")
@Produces("image/jpeg")
@Override
public Response getImage() {
    byte[] byteImage;
    try  {
        //Getting the image here
        ...
    } catch (ExceptionTypeA e) {
        return Response.status(204).entity(null).build();
    } catch (ExceptionTypeB e) {
        return Response.status(503).entity(null).build();
    }

    return Response.ok(image).build();
}
Run Code Online (Sandbox Code Playgroud)

这是我用来获取图像的代码:

...                 
Ion.with(imageView)
               .error(R.drawable.ic_menu_camera)
               .load(imageUrl).setCallback(new FutureCallback<ImageView>() {

                   @Override
                   public void onCompleted(Exception ex, ImageView iv) {
                       //I need to get the HTTP-status here.
                   } 
               });
...
Run Code Online (Sandbox Code Playgroud)

我也试过这个:

Ion
    .with(getApplicationContext())
    .load(imageUrl)
    .as(new TypeToken<byte[]>(){})
    .withResponse()
    .setCallback(new FutureCallback<Response<byte[]>>() {

        @Override
        public void onCompleted(Exception e, …
Run Code Online (Sandbox Code Playgroud)

rest android android-image android-ion android-imageview

0
推荐指数
1
解决办法
1842
查看次数

如何在Android Universal Image Loader中保存图像?

Lazy-List我使用此代码和我的图像存储在名为的文件夹中LazyList

ImageLoader imageLoader=new ImageLoader(context); imageLoader.DisplayImage(url, imageView);

但在Universal-Image-Loader我使用这个

 ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(getApplicationContext())    
            .build();
    ImageLoader.getInstance().init(config);
    img = (ImageView) this.findViewById(R.id.test_id);
    ImageLoader imageLoader = ImageLoader.getInstance();
    imageLoader.displayImage(URL.RECIPE_IMG_URL,img);
Run Code Online (Sandbox Code Playgroud)

但每次使用互联网来获取图像,并没有我的形象店口ASLO任何文件夹中一次添加.diskCache(new UnlimitedDiscCache(new File("myFolder")))config ,但没有商店myFolder.任何想法?

android android-image android-lazyadapter android-imageview universal-image-loader

0
推荐指数
1
解决办法
4851
查看次数

可以用"i"变量做findViewById吗?

我有9个ImageView具有相同ID但只更改数字(image1,image2等...).

我想在这个系统中初始化:

mImageView = new ImageView[9];

for(int i=0; i<mImageView.length; i++)
    mImageView[i] = (ImageView) findViewById(R.id.image+i);
Run Code Online (Sandbox Code Playgroud)

显然这是不可能的.但是有一个系统可以做到这一点吗?

android android-imageview

0
推荐指数
1
解决办法
352
查看次数

重叠两个圆形图像视图

我正在研究以下设计:

截图

我已经使用以下代码在android中实现了这个:

1.activity_welcome.xml

    <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/bg"
    android:orientation="vertical">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_marginTop="@dimen/margin40"
        android:text="Welcome to Almachat"
        android:textColor="#ffffff"
        android:textSize="20dp" />

    <com.almabay.almachat.circularImageView.CircularImageView
        android:layout_width="80dp"
        android:layout_height="80dp"
        android:layout_marginLeft="210dp"
        android:background="@drawable/color" />
    <com.almabay.almachat.circularImageView.CircularImageView
        android:id="@+id/profilePic"
        android:layout_width="200dp"
        android:layout_height="200dp"
        android:layout_gravity="center"
        android:layout_marginTop="-50dp" />

    <TextView
        android:id="@+id/txtName"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:textColor="#ffffff"
        android:textSize="30dp"
        android:textStyle="bold" />

    <TextView
        android:id="@+id/txtSomeText"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:text="Some static text will be here"
        android:textColor="#ffffff"
        android:textSize="20dp" />

    <Button
        android:id="@+id/btnContinue"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_marginTop="@dimen/margin20"
        android:background="#F7AE21"
        android:padding="@dimen/padding20"
        android:text="Continue"
        android:textColor="#ffffff" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

2. colors.xml

    <?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="oval">
    <gradient …
Run Code Online (Sandbox Code Playgroud)

android android-imageview

0
推荐指数
1
解决办法
1088
查看次数

ImageView在Android应用程序的构建中无法在CardView上运行

我正在学习在android studio上为android做一个应用程序,但我遇到了1个问题。我在CardView上添加了ImageView。在预览中,我可以看到ImageView,但是在构建中,我看不到。如何解决?

XML代码:

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
    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">

    <ScrollView
        android:id="@+id/scrollView2"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.49"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.51">

        <android.support.constraint.ConstraintLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <android.support.v7.widget.CardView
                android:id="@+id/cardView2"
                android:layout_width="393dp"
                android:layout_height="118dp"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintHorizontal_bias="0.0"
                app:layout_constraintStart_toStartOf="@+id/cardView"
                app:layout_constraintTop_toBottomOf="@+id/cardView">

                <android.support.constraint.ConstraintLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent">

                    <ImageView
                        android:id="@+id/imageView4"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="3dp"
                        android:layout_marginEnd="220dp"
                        android:adjustViewBounds="true"
                        android:contentDescription="@string/da"
                        android:cropToPadding="true"
                        android:scaleType="fitXY"
                        android:visibility="visible"
                        app:layout_constraintBottom_toBottomOf="parent"
                        app:layout_constraintEnd_toEndOf="parent"
                        app:layout_constraintStart_toStartOf="parent"
                        app:layout_constraintTop_toTopOf="parent"

    tools:srcCompat="@tools:sample/backgrounds/scenic[15]" />

                    <TextView
                        android:id="@+id/textView9"
                        android:layout_width="210dp"
                        android:layout_height="99dp"
                        android:layout_marginTop="8dp"
                        android:layout_marginBottom="8dp"
                        android:fontFamily="serif"
                        android:text="@string/tri"
                        android:textColor="@android:color/background_dark"
                        android:textSize="18sp"
                        android:textStyle="bold"
                        app:layout_constraintBottom_toBottomOf="parent"
                        app:layout_constraintEnd_toEndOf="parent"
                        app:layout_constraintHorizontal_bias="0.28"
                        app:layout_constraintStart_toEndOf="@+id/imageView4"
                        app:layout_constraintTop_toTopOf="parent"
                        app:layout_constraintVertical_bias="0.65999997" />
                </android.support.constraint.ConstraintLayout>
            </android.support.v7.widget.CardView>

            <android.support.v7.widget.CardView
                android:id="@+id/cardView"
                android:layout_width="385dp"
                android:layout_height="134dp"
                app:layout_constraintBottom_toTopOf="@+id/cardView2"
                app:layout_constraintEnd_toEndOf="parent" …
Run Code Online (Sandbox Code Playgroud)

android android-imageview android-studio android-cardview

0
推荐指数
1
解决办法
266
查看次数