简体   繁体   中英

java Android - how can I keep Image's actual size?

I'm totally confused of how to keep actual size of Images!

For example, I have a png named bottom_tile.png, if I place it on layout as it is - it's one size. If I make a tiled bitmap like this :

<bitmap xmlns:android="http://schemas.android.com/apk/res/android" 

  android:src="@drawable/ver_bottom_panel_tile"
        android:tileMode="repeat"
        android:dither="true"

/>    

and place it on my layout, it's height will be different, although it's only one tile high so they should be exact height! Why is it happening? both cases android:layout_height="wrap_content"

When I set another png file which should stick on top and stretch from left to right and set it's android:layout_height="wrap_content" , height is also distorted, so I can't place all the desing in. what's going on ?

I just need my actual size, no more no less

I've been asked for layout - it's just 2 images, 1 is a tile, 2nd is what's in code above bitmap is 40%+ bigger on it than a tile

<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"

    tools:context=".MainActivity" >

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:src="@drawable/ver_bottom_panel_tile" />

    <ImageView
        android:id="@+id/imageView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/imageView1"
        android:src="@drawable/ver_bottom_panel" />

</RelativeLayout>

can you be more specific about what you are looking for ?
If you need your image to attain a minimum or the original height you could use

android:layout_height="wrap_content"

this will make your image attain a minimum height or the original height

android:layout_width="fill_parent"

will make your image stretch left to right or width wise.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM