3

我喜欢这样设置 Imageview。

( http://wemakeucc.com/4.jpg ) <-请检查图片

到目前为止,我只使用这样的 imageview。

<ImageView
     android:id="@+id/a_01_b"
     android:layout_width="wrap_content"
     android:layout_height="match_parent" 
     android:src="@drawable/a_01_i" />

所以我想知道可以像该图像一样设置图像视图的代码。

我应该怎么办?

4

3 回答 3

2

请参阅下面的 xml

<?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" >

    <ImageView android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:layout_alignParentRight="true"
       android:layout_marginRight="40dip"
       android:layout_marginTop="60dip" // give dip value according to where you want to place first image view from top
       android:background="@color/black" // set image according to you
       android:id="@+id/imageviewone" />

    <ImageView android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:layout_alignParentLeft="true"
       android:layout_marginLeft="40dip"
       android:layout_marginTop="60dip" // give dip value what you have given to first edit text
       android:background="@color/black" // set image according to you
       android:layout_below="@+id/imageviewone"
       android:id="@+id/imageviewtwo" />
    </RelativeLayout>

让我知道这是否对您有帮助

于 2013-02-19T13:57:09.800 回答
1

这是根据您的要求的代码:

xml文件:和截图

<?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="vertical" >

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:gravity="right"
        android:orientation="vertical"
        android:paddingBottom="30dp"
        android:paddingRight="20dp"
        android:paddingTop="20dp" >

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/android" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:gravity="right"
        android:orientation="vertical"
        android:paddingBottom="30dp"
        android:paddingRight="120dp"
        android:paddingTop="20dp" >

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/android" />
    </LinearLayout>

</LinearLayout>

在此处输入图像描述

现在只需根据您的需要设置填充...

于 2013-02-19T14:10:53.397 回答
-1

您正在寻找的答案在 [ LayoutParams][1] 中。

回答你的问题:

ImageView iv = (ImageView)findViewById(R.id.my_imageView);
AbsoluteLayout.LayoutParams absParams = 
    (AbsoluteLayout.LayoutParams)iv.getLayoutParams();
absParams.x = myX;
absParams.y = myY;
iv.setLayoutParams(absParams);

解释:您正在为您的 ImageView 设置某种锚点(x/y(

于 2013-02-19T13:55:10.993 回答