logo
down
shadow

Scale image in ImageView to width of the parent and scale in height accordingly


Scale image in ImageView to width of the parent and scale in height accordingly

By : user2956864
Date : November 22 2020, 03:03 PM
will help you Put all in one file to make it more clear, together with code and result: , try this..
code :
<ImageView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:adjustViewBounds="false"
    android:background="@drawable/image1"/>
<?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:orientation="horizontal"
    android:weightSum="2"
    android:gravity="right" >

   <ImageView
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:adjustViewBounds="false"
    android:layout_gravity="right"
    android:layout_weight="1"
    android:background="@drawable/ic_launcher"/>

</LinearLayout>
<?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:gravity="right"
    android:orientation="vertical"
    android:weightSum="10" >

    <ImageView
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:background="@drawable/ic_launcher" />


</LinearLayout>


Share : facebook icon twitter icon
Scale image with css to both width and height to scale

Scale image with css to both width and height to scale


By : Andreas Korinek
Date : March 29 2020, 07:55 AM
I hope this helps . The bounding box is approx 1000x600, and some images are 500x100, while some others are 400x100 (extreme examples). Now I'd like to scale both up to the maximum size the bounding box is capable to handle, but keep them to scale. , You can set only width or only height to 100%. E.g.
code :
img {
    width: 100%;
}
img {
    height: 100%;
}
Android: Trying to scale a ImageView, so image fills width and scaled to height

Android: Trying to scale a ImageView, so image fills width and scaled to height


By : Pablo Steil
Date : March 29 2020, 07:55 AM
hope this fix your issue Yes, there's an extremely easy way to do this:
Just use the following code to rescale your bitmap:
code :
ImageView picImage = (ImageView) findViewById(0);// R.id.viewpic);
try {
String FileName = "canon20.png";
AssetManager assetManager = getAssets();
InputStream inputStream;
inputStream = assetManager.open(FileName);
Bitmap icon = BitmapFactory.decodeStream(inputStream);

int screenWidth = getWindowManager().getDefaultDisplay().getWidth();
int screenHeight = getWindowManager().getDefaultDisplay().getHeight();
int bw = icon.getWidth();
float t = (float) screenWidth / (float) bw;

picImage.setImageBitmap(icon);
picImage.getLayoutParams().width = screenWidth;
picImage.getLayoutParams().height = (int) (icon.getHeight() * t);
// The following line is the one that scales your bitmap.
Bitmap scaledIcon = Bitmap.createScaledBitmap(icon, screenWidth, (int) icon.getHeight() * t, false);
} catch (IOException e) {
}
Android ImageView scale smaller image to width with flexible height without cropping or distortion

Android ImageView scale smaller image to width with flexible height without cropping or distortion


By : Pallino Framba
Date : March 29 2020, 07:55 AM
this will help There is no viable solution within the XML layout standard.
The only reliable way to react to a dynamic image size is to use LayoutParams in code.
ImageView Scale and Width/Height change

ImageView Scale and Width/Height change


By : jacksen
Date : March 29 2020, 07:55 AM
will be helpful for those in need Assuming your fullscreenImageView extends ImageView you can add this method in your fullscreenImageView
code :
    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    super.onMeasure(widthMeasureSpec, heightMeasureSpec);
    int width = MeasureSpec.getSize(widthMeasureSpec);
    int height = width * getDrawable().getIntrinsicHeight() / getDrawable().getIntrinsicWidth();
    setMeasuredDimension(width, height);
}
Fill width and scale height accordingly ImageView Android

Fill width and scale height accordingly ImageView Android


By : Claude
Date : March 29 2020, 07:55 AM
this one helps. I actually made a widget for this. You basically just put the ImageView inside of the RatioRelativeLayout (this widget: https://github.com/elimirks/RatioRelativeLayout).
The example is on the github page, but I will paste it here as well:
code :
<my.package.RatioRelativeLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    heightRatio="0.75"
>
    <View
        android:layout_width="25dp"
        android:layout_height="match_parent"
        android:background="#f00"
    />
</my.package.RatioRelativeLayout>
Related Posts Related Posts :
  • Can not scroll and click item on gridview inside scrollview
  • Android device keeps disconnecting from adb / eclipse
  • Volley cannot create cache directory. Could not clean up file
  • ShareActionProvider icon in actionbar
  • How to open a custom attachment using an Android app?
  • Unable to add column dynamically into the sqlite table
  • android persistence activity which never stop
  • The Google Play services resources were not found. Check your project configuration to ensure that the resources are inc
  • How to select files from google drive in android?
  • Run a AsyncTask every 10 seconds until cancelled
  • Blur on touch. Android application
  • NDK Android - Can't build ARMv5 and V7 at the same time
  • Android development with Eclipse clean and build
  • How to set Different Key Background for every Key in Android Custom Keyboard
  • Face recognition using OpenCV in android?
  • Tumblr API - Jumblr for Android [OAuthConnectionException]
  • Small Icon on Notification not working correctly
  • ConstraintLayout match parent height on larger screens but scroll on smaller
  • Kotlin version issue
  • How can i make my android app look the same on RTL and LTR languages?
  • Can not detect Android NDK toolchain
  • Falling back on PROMPT mode since _cordovaNative is missing. Expected for Android 3.2 and lower only.
  • Facebook Key Hash for Play Store Release
  • backbutton confirm exit app android + phonegap + jquery
  • How to Make Instagram Listview in android?
  • Up and Down Enemy Movement using translate corona sdk
  • Set selection method is not working in gallery in android
  • How to implement onOptionsItemSelected for Sub-Menu Items?
  • HttpHostConnectException connection refused ConnectException ErrnoException
  • Adding Buttons to expendableListView as last Child
  • Android. Block phone on startup
  • How to programmatically check If string is not to wide to fit onto the screen in Android
  • EditText box cursor appear after touching box?
  • using if statement when video is done playing
  • Add to Aspectpath not found MonkeyTalk
  • GooglePlusUtil cannot be resolved (Android)
  • Trouble understanding Relative Layout
  • How to title/name each fragment separately to appear on PagerTitleStrip?
  • Android webView blinks
  • Available service types in WifiP2pDnsSdServiceInfo.newInstance
  • Hide only bottom action bar Android
  • Android + MoPub + PhoneGap (Cordova) Integration (Half working)
  • Android OnTouchListener results in jerky drags
  • android notification disappears after reboot
  • Optimising Canny Edge Detector for Android
  • How to Play the online streaming radio in Android
  • Blurry map tiles at start of android app based on google Maps API v2
  • How to combine java native within the XML android and dart Flutter
  • Intercept the outgoing call data, alter it & then write it back out- Why it is not possible?- Android
  • Bundle extra sends wrong string
  • Display a view using windowmanager on lock screen
  • is it possible to load images from the directory on web server?
  • android SDK manager, only show installed package
  • How to handle time zone difference between server and native android application?
  • ViewPager PagerAdapter delete items
  • How to solve different Preview/Picture sizes returned by android.hardware.camera?
  • How to get songs from album/Artist in android,using MediametadataRetriever?
  • Android UIAutomator how to tilt device
  • DialogFragment issues with screen orientation and MediaController
  • blank screen after re-starting launcher activity (failed binder transaction)
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org