Adjusting the picture position as shown in the figure

I like to install Imageview as follows.

( http://wemakeucc.com/4.jpg ) <-Check image please

I only use this image so far.

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

      

so I want to know the code that can set the image as such an image.

what should I do?

+3


source to share


3 answers


here is the code as per your requirement:

xml file: and screenshots

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

      



enter image description here

now just install the add-on as needed ...

+1


source


See the following xml below

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

      



let me know if it helps you

+2


source


The answer you are looking for is in [ LayoutParams

] [1].

to answer your question:

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

      

Explanation: you are setting some kind of anchor point (x / y (for your ImageView

-1


source







All Articles