A
A
Alexander2014-06-05 08:56:32
JavaScript
Alexander, 2014-06-05 08:56:32

Android: Align Vertical and Raise 60 dp

Hello!
There is a RelativeLayout layer:

<RelativeLayout
        android:id="@+id/redcircle"
        android:layout_width="8dp"
        android:layout_height="8dp"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:background="@drawable/circle" >
</RelativeLayout>

The question is how to "raise" it another 60dp relative to this center?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
D
Denis Ineshin, 2016-01-08
@iam_not_a_robot

returnonly makes sense in synchronous functions. Like this:

function calc (a, b) {
    return a + b;
}

var c = calc (2, 2); // 4

In asynchronous functions, return does not make sense, since nothing is returned at the time the code is executed.
Think for yourself, in your case, before the onset of the mousemove event, it can take a very long time.
Therefore, they work differently with asynchronous code. Here is an example on callbacks:
document.addEventListener("mousemove", function (e) {
  var coord = [];
  coord[0] = e.clientX+'px';
  coord[1] = e.clientY+'px';

  next(coord); // вызов коллбэка
});

function next (coord) {
  console.log(coord);
}

There are other approaches besides callbacks, such as promises . jQuery has a cross browser implementation .

P
Peter, 2016-01-08
@petermzg

In the first variant, you have coord as a local variable.
And in the second option, you override the global coord with the local one.
Delete the selection and you will be happy

A
Alexander, 2014-06-05
@cry_san

The problem was solved like this:

<RelativeLayout
        android:layout_width="8dp"
        android:layout_height="68dp"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true" >
   	
      <ImageView
    android:id="@+id/redcircle"
          android:layout_width="8dp"
          android:layout_height="8dp"
          android:src="@drawable/circle" />        
  </RelativeLayout>

Thanks to all!

I
IceJOKER, 2014-06-05
@IceJOKER

try setting margin(or layout_margin don't remember exactly) -60dp

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question