0

我正在尝试在两种不同的布局中设置两个图像。

图像的分辨率大小:986 * 569。

0.50 重量的布局

如下所示:

  <?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:background="@drawable/bluebg"
   android:orientation="vertical" >

<LinearLayout
    android:id="@+id/AmLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_weight=".50">

    <ImageView
        android:id="@+id/imageAm"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:src="@drawable/am"
        android:visibility="visible" />
</LinearLayout>

<LinearLayout
    android:id="@+id/horibreak1"
    android:layout_width="match_parent"
    android:layout_height="2dp"
    android:background="#000000"
    android:orientation="vertical" >
</LinearLayout>

<LinearLayout
    android:id="@+id/PmLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_weight=".50">

    <ImageView
        android:id="@+id/imagePm"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:src="@drawable/pm"
        android:visibility="visible" />
</LinearLayout>
</LinearLayout>

问题是图像未拉伸到完整布局。如何解决这个问题?

我得到类似的东西:http: //i.imgur.com/GT6es7o.png ?1

4

3 回答 3

1

Try this

1.)<?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:background="@drawable/bluebg"
   android:orientation="vertical" >
   <LinearLayout
    android:id="@+id/AmLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_weight=".50"
    android:background ="@drawable/am"/>
   <LinearLayout
    android:id="@+id/horibreak1"
    android:layout_width="match_parent"
    android:layout_height="2dp"
    android:background="#000000"
    android:orientation="vertical" />
    <LinearLayout
    android:id="@+id/PmLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background ="@drawable/Pm"
    android:layout_weight=".50"/>
</LinearLayout>

2.) <?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:background="@drawable/bluebg"
   android:orientation="vertical" >

<LinearLayout
    android:id="@+id/AmLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
   >

    <ImageView
        android:id="@+id/imageAm"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:src="@drawable/am"
        android:layout_weight=".50"
        android:scaletype ="fitXY"
        android:visibility="visible" />
</LinearLayout>

<LinearLayout
    android:id="@+id/horibreak1"
    android:layout_width="match_parent"
    android:layout_height="2dp"
    android:background="#000000"
    android:orientation="vertical" >
</LinearLayout>

<LinearLayout
    android:id="@+id/PmLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
   >

    <ImageView
        android:id="@+id/imagePm"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:src="@drawable/pm"
        android:layout_weight=".50"
        android:scaletype ="fitXY"
        android:visibility="visible" />
</LinearLayout>
</LinearLayout>
于 2013-08-05T05:38:20.560 回答
0

set image view property as

android:scaleType="centerCrop"

or

android:scaleType="fitXY"
于 2013-08-05T05:40:08.690 回答
0

你可以试试这个,如果你知道图像的文件路径,那么

你的路径:

File photo= new File(imagepath);

然后:

Bitmap bitmap = decodeFile(photo);
bitmap = Bitmap.createScaledBitmap(bitmap,350, 350, true);
imageView.setImageBitmap(bitmap);
于 2013-08-05T05:33:59.037 回答