标签: android-imageview

ImageView没有正确缩小图像中心


我无法在ImageView中正确缩放图像并使其居中.
向上扩展时,没有问题,但是当缩小时,图像不再显示居中,并且ImageView的边界是错误的,如下所示:

problem.png

<?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">
    <ImageView
        android:src="@drawable/stereomood_splash"
        android:scaleType="fitCenter"
        android:id="@+id/imageView1"
        android:layout_width="100dip"
        android:layout_height="200dip"></ImageView>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

这是一个错误,有没有人找到解决方法?

android android-layout android-imageview

2
推荐指数
1
解决办法
3123
查看次数

如何在ANDROID中禁用像Iphone这样的图像?

我想在我的应用程序中禁用图像视图.(如iphone).当我的活动启动时,我在Imageview中显示一个图像,然后如果我点击图像我想让它禁用它.在某种意义上禁用它将变得更加透明.

谢谢....

android android-imageview

2
推荐指数
1
解决办法
2012
查看次数

Android在imageview中对齐顶部位图

无论如何,我可以将位图对齐ImageView.我的图片视图有问题.我正在通过Java代码设置它的源代码,并且在调整位图大小后将其置于中心位置ImageView,但我想要的是对齐位图.

声明imageView:

    <RelativeLayout
    android:id="@+id/collection_background"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_below="@+id/actionbar" > 


     <ImageView  
        android:id="@+id/collection_image_background"
        android:layout_width="fill_parent"
        android:layout_height="match_parent"
        android:background="#ffffff"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:contentDescription="@string/stampii"  />

    // countinue ........
Run Code Online (Sandbox Code Playgroud)

这是我如何设置位图:

BitmapFactory.Options o2 = new BitmapFactory.Options();
    o2.inTempStorage = new byte[8*1024];

    ops = BitmapFactory.decodeStream(cis,null,o2);
    ImageView view = (ImageView) findViewById (R.id.collection_image_background);        
    view.setImageBitmap(ops);
Run Code Online (Sandbox Code Playgroud)

任何想法如何做到这一点?

android android-imageview

2
推荐指数
1
解决办法
9088
查看次数

如何在网格布局中正确对齐图像下方的文本,并在超出图像宽度时使其占据第二行?

我的XML:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#FFFFFF"
    android:orientation="vertical" >

    <ImageView
        android:id="@+id/imageMenu"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_below="@id/signOut"
        android:layout_centerInParent="true"
        android:layout_marginLeft="10dip"
        />

    <TextView
        android:id="@+id/gridtext"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/imageMenu"
        android:layout_marginLeft="10dip"
        android:layout_marginTop="10dip"
        android:layout_centerHorizontal="true"
        android:text="TextView"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:textColor="#000" />

</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

我可以在此网格布局中将图像设置在图像的正下方,但是如果文本太大,我还希望将文本包装到下一行.例如,我有一个"血库"的图像,文字是"最近的血库".我希望它包含在图像的宽度内.怎么做?

android textview android-layout android-imageview

2
推荐指数
1
解决办法
9346
查看次数

Android - 如何放大位图

我通常下载尺寸较大的图像并使用imageview缩小它们但最近我试图处理我的应用程序不能在较小的网络连接上工作,所以我想知道如何在图像到达设备后增加图像的大小.我尝试在图像视图中调整图像大小,但图像视图不会比原始图像大.我确定这是一个非常简单的方法来增加或炸毁设备上的图像,但我还没有遇到它.

那么.....我怎样才能增加图像的大小.我喜欢将它炸毁并在imageview中使用它,但我处理的图像只有128X256,我喜欢将它们扩展到大约512X1024.

android bitmap android-imageview

2
推荐指数
1
解决办法
5998
查看次数

图像滑动和更改按钮也是如此

我正在尝试制作一个画廊应用程序.我有两个"下一个"和"后退"按钮,当我按下下一个按钮时,我需要显示下一个图像,我还需要通过滑动来更改图像.我尝试过使用图像适配器.但我不知道用按钮改变图像.

android android-imageview android-viewpager

2
推荐指数
1
解决办法
2928
查看次数

从strings.xml提供layout_height和layout_width

我试图ImageView从常量字符串设置高度和宽度strings.xml,如下所示:

 <ImageView
            android:id="@+id/GetMailing"
            android:layout_width="@string/continueBtnWidthHD"
            android:layout_height="@string/continueBtnHeightHD"
            android:layout_gravity="center"
            android:src="@drawable/continue_button_style" />
Run Code Online (Sandbox Code Playgroud)

strings.xml,我有:

<string name="continueBtnHeightHD">60dp</string>
<string name="continueBtnWidthHD">250dp</string>
Run Code Online (Sandbox Code Playgroud)

但这会在执行时出错setContentView(view_Id).

错误是java.lang.RuntimeException:二进制XML文件行#82:您必须提供layout_width属性.

我正在使用这种方法,因为我想在不同的地方使用相同的值.

这有点奇怪,因为我用同样的方法来设置maxlengthEditText,它的工作的罚款.

我做错了吗?

任何帮助赞赏.

java xml android android-layout android-imageview

2
推荐指数
1
解决办法
2937
查看次数

圆角ImageView - Android

我尝试创建带圆角的imageview.i搜索并找到xml代码

<?xml version="1.0" encoding="utf-8"?>
Run Code Online (Sandbox Code Playgroud)

<solid android:color="#00ffffff" />

<padding
    android:bottom="6dp"
    android:left="6dp"
    android:right="6dp"
    android:top="6dp" />

<corners android:radius="12dp" />

<stroke
    android:width="6dp"
    android:color="#ffffffff" />
Run Code Online (Sandbox Code Playgroud)

这是我的imageview xml代码

<ImageView
                android:id="@+id/slidemenuuserimage"
                android:layout_width="90dp"
                android:layout_height="90dp"
                android:layout_alignParentBottom="true"
                android:layout_alignParentLeft="true"
                android:layout_marginBottom="16dp"
                android:layout_marginLeft="14dp"
                android:background="@drawable/frame" />
Run Code Online (Sandbox Code Playgroud)

我有一个问题.当我以编程方式添加背景图像时,我收到了divirent结果.

slidemenuuserimage=(ImageView)findViewById(R.id.slidemenuuserimage);
    slidemenuuserimage.setBackgroundResource(R.drawable.myuserimg);
Run Code Online (Sandbox Code Playgroud)

这是我的结果 在此输入图像描述

如何以编程方式向左或向右添加填充.在我的选项中,这是我的问题,如果有人知道解决方案请帮助我

android rounded-corners android-imageview

2
推荐指数
1
解决办法
1万
查看次数

如何在android中单击imageview时突出显示图像视图的边框

我在android中的水平视图中有图像列表.如果我单击特定图像的图像视图必须以编程方式突出显示边框颜色.如何为图像视图的突出显示边框执行此操作.提前致谢.

想要显示如下所述的边框

当用户单击ImageView的单个图像时,我想显示像ImageView的这个边框.

horizontalimage=(LinearLayout)findViewById(R.id.linearimage);
                                               // final RelativeLayout r1=(RelativeLayout)findViewById(R.id.relative_border);
                                             //   frame=(FrameLayout)findViewById(R.id.framelayout
  if(multipleimage.length()>0) {
  for (int j = 0;j<multipleimage.length();j++)
    {
    pimages=multipleimage.getJSONObject(j);
    JSONObject oneimage=multipleimage.getJSONObject(0);
    ii= new ImageView(singleshooppingcart.this);
    multipleimages=(ImageView)findViewById(R.id.singleimage);

   ii.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
   LinearLayout.LayoutParams image = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
   image.width=100;
   image.height=1
   image.setMargins(5,0,0,0);


   final String multimgs=pimages.getString("original_res");
   String oneimg=oneimage.getString("original_res");


   String[] img2 = multimgs.split("\\.");
   String imagone=productpath + alertObj.getString("seller_id")+  '/' + img2[0] + '(' + '1' + '0' + '0' + ')' + '.' + img2[1];
   String singleiamges=productpath + alertObj.getString("seller_id")+  '/' + oneimg;
// displayimages=productpath + alertObj.getString("seller_id")+  '/' + multimgs[];
   YelloPage.imageLoader.displayImage(imagone, …
Run Code Online (Sandbox Code Playgroud)

android android-layout android-imageview android-fragments android-studio

2
推荐指数
1
解决办法
6211
查看次数

当我使用fit()时Android Picasso没有加载图片

没有fit()它工作正常.
.Picasso.with(getApplicationContext())的负载(url.concat(featureImage))代入(ImageView的).

ImageView imageView = (ImageView)findViewById(R.id.featureImage);
TextView textTitle = (TextView)findViewById(R.id.title);
TextView textDetail = (TextView)findViewById(R.id.detail); 
 Picasso.with(getApplicationContext()).load(url.concat(featureImage)).fit().into(imageView);
textTitle.setText(title);
textDetail.setText(detail);
Run Code Online (Sandbox Code Playgroud)

android android-imageview picasso

2
推荐指数
1
解决办法
1464
查看次数