标签: imageview

适合 ReyclerView 项目中 imageView 的图像宽度

我目前可以使用此代码。我正在做的是使用 Picasso 下载图像并将其加载到 imageView 中,该 imageView 位于 RecyclerView 项内。

回收者项目 XML

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/card_item"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:cardPreventCornerOverlap="false"
    app:cardElevation="4dp"
    app:cardCornerRadius="4dp"
    app:cardUseCompatPadding="true">

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <!-- Loading View -->
        <com.wang.avi.AVLoadingIndicatorView
            android:id="@+id/avloadingitem"
            android:layout_width="50dp"
            android:layout_height="50dp"
            android:layout_gravity="center"
            android:visibility="gone"
            app:indicator="BallClipRotate"
            app:indicator_color="@color/colorAccent"/>

        <!-- Imagen -->
        <com.wallakoala.wallakoala.Views.ProductImageView
            android:id="@+id/grid_image"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:riv_corner_radius_bottom_left="4dp"
            app:riv_corner_radius_bottom_right="4dp"
            app:riv_corner_radius_top_left="4dp"
            app:riv_corner_radius_top_right="4dp"/>

        <!-- Pie de foto -->
        <RelativeLayout
            android:id="@+id/footer"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom"
            android:alpha="0.75">

            <!-- Info extra -->
            <include android:id="@+id/extraInfo"
                layout="@layout/product_footer_extra"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:visibility="visible"/>

            <!-- Info principal -->
            <include android:id="@+id/mainFooter"
                layout="@layout/product_footer"
                android:layout_height="@dimen/footer_height"
                android:layout_width="match_parent" …
Run Code Online (Sandbox Code Playgroud)

android image imageview picasso android-recyclerview

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

ImageView 捏合缩放

嗨,我想放大图像视图。我设置了缩放事件。但缩放位置时我无法更改。你能帮助我吗?

活动主文件

<ImageView
    android:id="@+id/imageView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:scaleType="matrix"
    android:src="@mipmap/asd" />
Run Code Online (Sandbox Code Playgroud)

MainActivity.class

public class MainActivity extends AppCompatActivity {

ImageView imageView;
android.graphics.Matrix matrix = new android.graphics.Matrix();
Float scale = 1f;
ScaleGestureDetector SGD;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    imageView = (ImageView) findViewById(R.id.imageView);
    SGD = new ScaleGestureDetector(this,new ScaleListener());

}

private class ScaleListener extends ScaleGestureDetector.SimpleOnScaleGestureListener{
    @Override
    public boolean onScale(ScaleGestureDetector detector) {
        scale = scale * detector.getScaleFactor();
        scale = Math.max(0.1f,Math.min(scale,5f));
        matrix.setScale(scale, scale);
        imageView.setImageMatrix(matrix);
        return true;
    }
}

@Override
public boolean onTouchEvent(MotionEvent event) {
    SGD.onTouchEvent(event); …
Run Code Online (Sandbox Code Playgroud)

android zooming imageview android-imageview pinchzoom

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

在 Swift 中设置可拖动项目的限制

我有一个图像视图和该图像上的文本字段。我使用下面的代码使文本字段可拖动,但它可以拖动到屏幕中的任何位置。我希望该文本字段只能在图像视图的限制内拖动。如果我取消注释,如果检查 dragedView 函数,则文本字段会卡在 imageview 的左侧,因为它们的 x 值变得相同。

我找到了这个解决方案,但无法修改它以适用于我的项目。 使用 UIPanGestureRecognizer 将 UIView 拖动到有限区域内

  override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.
    let gesture = UIPanGestureRecognizer(target: self, action: #selector(ViewController.draggedView(_:)))
    bottomTextField.addGestureRecognizer(gesture)
    bottomTextField.isUserInteractionEnabled = true
}
  func userDragged(gesture: UIPanGestureRecognizer){
    let loc = gesture.location(in: self.view)
    self.bottomTextField.center = loc
}
func draggedView(_ sender:UIPanGestureRecognizer) {
    let compare = MyimageView.frame.maxX <= bottomTextField.frame.maxX
    //if(MyimageView.frame.minX <= bottomTextField.frame.minX && compare )
    // {
    self.view.bringSubview(toFront: sender.view!)
    let translation = sender.translation(in: self.view) …
Run Code Online (Sandbox Code Playgroud)

view textfield imageview ios swift

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

带有右下角圆形彩色徽章的圆形 ImageView

这是 RecyclerView 需要膨胀的布局类型。

在此输入图像描述

我使用 CircleImageView 库来实现圆形图像。(https://github.com/hdodenhof/CircleImageView

现在我的问题是,如何让另一个背景(实际上只是一种颜色)出现在它上面(就像上图中的蓝色部分)

这是迄今为止我所取得的成就。

在此输入图像描述

有什么建议么?

layout android imageview android-layout android-recyclerview

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

根据 tableview javafx 内的条件设置图标

我正在构建一个应用程序,它将根据特定条件显示图像。目前,我的数据显示在 JavaFX 上的表格视图中。我的可观察模型类仅包含有关用户输入信息的信息。我需要比较表视图类中的信息并在称为状态的指定列之一内显示图像。

TableColumn<StudentRecord, ImageView> statusCol = new TableColumn<>("Status"); 
Run Code Online (Sandbox Code Playgroud)

我遵循了不同的答案,但找不到合适的解决方案。我这样做是为了循环遍历所有对象并显示图标。但这种方法会在每一行上显示图标。

dataController.getAllData().forEach(studentRecord -> {
                    if (studentRecord.getDate().equalsIgnoreCase("some date")) {

                        statusCol.setCellValueFactory(c -> new SimpleObjectProperty<ImageView>(new ImageView("/images/tick.png")));
                    }else{
                        statusCol.setVisible(false);
                    }
                }
        );
Run Code Online (Sandbox Code Playgroud)

我尝试了 StackOverflow 的不同答案,但无法正确实现它。知道如何解决这个问题吗?

javafx tableview imageview

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

图像已导入到可绘制文件夹,但在尝试将其设置为 ImageView 时未显示

我将三个图像导入到我的 Android Studio(版本 3.1.3)项目中,方法是将它们拖动到可绘制文件夹(2 png、1 jpg),然后选择“文件”>“与 Gradle 文件同步项目”。

在 xml 文件 Activity_main.xml(文本模式)中,我输入android:src="@drawable/"并得到 2 张 png 图像作为建议,但不是我想要使用的图像(jpg 图像)。

然后我尝试在设计模式下使用 Activity_main.xml 设置 src 组件,选择 ImageView > src > ... 。这将打开一个包含可绘制内容(项目、android、主题属性)的窗口。进入 Drawbale>Project,我看到默认的 android 图像和我导入的两个 png 图像,但 jpg 不存在。

然后我删除所有三个图像,同步项目与 Gradle 文件,将 jpg 文件添加到可绘制文件,同步项目与 Gradle 文件,但当我尝试添加它时仍然没有显示它。

我看到有人在某个地方发布了他在可绘制文件夹中的第一个图像有一个错误,他再次导入具有不同名称的相同图像,这对他有用,尝试过但没有成功。

android src drawable imageview

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

在 Swift 中反转透明图像的颜色

我已经下载了这张具有透明背景的图片,并将其放入“图像视图”中,只是想知道是否有可能将图像的轮廓反转为白色而不是黑色?我的背景是蓝色的,这就是它看起来像现在这样的原因。非常感谢大家的帮助!谢谢!

在此输入图像描述

colors imageview swift

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

在运行时向ImageView添加边框和其他一些样式

我目前的代码:

    LinearLayout.LayoutParams params = new TableLayout.LayoutParams(
            LinearLayout.LayoutParams.WRAP_CONTENT,
            LinearLayout.LayoutParams.WRAP_CONTENT);

        ImageView imageview= new ImageView(this);
        imageview.setImageBitmap(bmp);
        imageview.setLayoutParams(params);
        layout.addView(imageview);
Run Code Online (Sandbox Code Playgroud)

如何为此imageview添加边框?我试过了:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <shape android:shape="rectangle">
            <gradient android:angle="90"
                      android:startColor="@color/image_border_start"
                      android:centerColor="@color/image_border_center"
                      android:endColor="@color/image_border_end" />
        </shape>
    </item>
    <item android:top="1dp" android:left="1dp"
          android:right="1dp" android:bottom="1dp">
        <shape android:shape="rectangle">
            <solid android:color="@color/default_back_color" />
        </shape>
    </item>
</layer-list>
Run Code Online (Sandbox Code Playgroud)

而且iv.setImageResource(R.drawable.style);,然后它只显示这个边框,而不是图像.可能吗?

java android imageview

-1
推荐指数
1
解决办法
3522
查看次数

如何从圆形的URL中加载图像视图中的图像?

我创建了一个Android应用程序,我想在圆形的图像视图中显示图像.

我的代码是:

    private class LoadImage extends AsyncTask<String, Void, String> 
    {
        Bitmap image=null;
        @Override
        protected String doInBackground(String... params) 
        {
            try 
            {
                URL url = new URL(imgUrl);
                image = BitmapFactory.decodeStream(url.openConnection().getInputStream());              
                image=Global.getRoundedShape(image);                                
            } 
            catch (Exception e) 
            {
                e.printStackTrace();
            }
            return "Executed";
        }
        @Override
        protected void onPostExecute(String code) 
        {
            try
            {
                profilepic.setImageBitmap(image);
            }
            catch (Exception e) 
            {
                e.printStackTrace();
            }
        }    
    }


public static Bitmap getRoundedShape(Bitmap scaleBitmapImage) 
{
    int targetWidth = 168;
    int targetHeight = 166;
    Bitmap targetBitmap = Bitmap.createBitmap(targetWidth, 
                        targetHeight,Bitmap.Config.ARGB_8888);

    Canvas canvas = new …
Run Code Online (Sandbox Code Playgroud)

url android imageview

-1
推荐指数
1
解决办法
5678
查看次数

如何在Android Studio上制作Circle ImageView

我知道这个问题上有很多例子,但我仍然无法完成它们,是否有一个简单的方法如何在android studio上制作圆形ImageView?

android imageview

-1
推荐指数
1
解决办法
2825
查看次数