Android Image Dialog/Popup same size as image and no border

后端 未结 5 1841
盖世英雄少女心
盖世英雄少女心 2020-12-23 14:35

At the moment I am working on a file browser. Everything works fine with one exception: If the user clicks on an image (jpg, png, bmp, ..), I want the image to be displayed

相关标签:
5条回答
  • 2020-12-23 15:13

    Add single line code under your image view initialization into your activity and it will solve your problem..

    image.setScaleType(ImageView.ScaleType.FIT_XY); 
    
    0 讨论(0)
  • 2020-12-23 15:17

    Have u tried set setType in ImageView?

    <ImageView ... android:scaleType="fitXY" ... />

    0 讨论(0)
  • 2020-12-23 15:26

    you can make a custom dialog for showing images , make a layout for inflating in dialog's setcontentview , take one linear layout with width and height wrap content and imageview with in it with scale property fitxy .

    0 讨论(0)
  • 2020-12-23 15:29

    Change your ImageView from this:

    <ImageView
            android:id="@+id/thumbnail_IMAGEVIEW"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_alignParentTop="true"
            android:contentDescription="@string/icon_DESCRIPTION" />
    

    To this:

    <ImageView
            android:id="@+id/thumbnail_IMAGEVIEW"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_alignParentTop="true"
            android:adjustViewBounds="true" <!-- Here is the thing -->
            android:contentDescription="@string/icon_DESCRIPTION" />
    

    Hope this helps.

    0 讨论(0)
  • 2020-12-23 15:37

    Use FrameLayout as it's parent rather than RelativeLayout and set to wrap_content and 0 margins.

    Try:

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:paddingBottom="@dimen/activity_vertical_margin"
    tools:context=".MainActivity"
    android:background="@color/background">
    
    <FrameLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/frameLayout"
            android:background="#b2ff7c">
    
        <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/imageView"
                android:src="@drawable/ic_launcher"/>
    </FrameLayout>
    
    </RelativeLayout>
    

    The result should be a background the same size as the ImageView.

    If this does work. Try modifying this in a custom theme:

        <style name="Widget.ImageWell">
        <item name="android:background">@android:drawable/panel_picture_frame_background</item>
        </style>
    
    0 讨论(0)
提交回复
热议问题