Skip to content
This repository has been archived by the owner on Feb 8, 2022. It is now read-only.

Incorrect position on left using androidx imagebutton #64

Open
fabrizziocht opened this issue Jan 2, 2019 · 2 comments
Open

Incorrect position on left using androidx imagebutton #64

fabrizziocht opened this issue Jan 2, 2019 · 2 comments

Comments

@fabrizziocht
Copy link

Hello, I'm trying to display tooltip but position doesn't match, here is my code:

<layout xmlns:tools="http://schemas.android.com/tools"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:android="http://schemas.android.com/apk/res/android"
        tools:context=".ui.Main.MainActivity">
    <data>
        <variable name="vm" type="com.webcontrol.earlyalert.vm.MainViewModel" />
    </data>
    <androidx.constraintlayout.widget.ConstraintLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">
        <androidx.constraintlayout.widget.ConstraintLayout
                android:padding="16dp"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:layout_constraintTop_toTopOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintEnd_toEndOf="parent" android:id="@+id/constraintLayout">
            <TextView android:text="@{vm.nombreUsuario()}"
                      android:layout_width="0dp"
                      android:layout_height="wrap_content"
                      app:layout_constraintStart_toStartOf="parent"
                      app:layout_constraintTop_toTopOf="parent"
                      android:layout_marginTop="16dp"
                      android:textSize="24sp"
                      android:fontFamily="sans-serif-medium"
                      android:id="@+id/textView"
                      android:layout_marginEnd="8dp"
                      app:layout_constraintEnd_toStartOf="@+id/imageView"/>
            <Button
                    android:minHeight="0dp"
                    android:minWidth="0dp"
                    android:textAlignment="viewStart"
                    style="?android:attr/borderlessButtonStyle"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/cerrar_sesion"
                    android:onClick="cerrarSesion"
                    android:fontFamily="sans-serif-light"
                    app:layout_constraintTop_toBottomOf="@+id/textView"
                    app:layout_constraintStart_toStartOf="parent"
                    android:id="@+id/btn_cerrar_sesion"/>


            <ImageView android:layout_width="64dp"
                       android:layout_height="64dp"
                       android:scaleType="centerInside"
                       android:adjustViewBounds="true"
                       android:contentDescription="@string/imagen_usuario"
                       android:src="@drawable/default_user"
                       app:layout_constraintEnd_toEndOf="parent"
                       app:layout_constraintTop_toTopOf="parent"
                       android:id="@+id/imageView"/>
            <View android:layout_width="match_parent"
                  android:layout_height="1dp"
                  android:layout_marginTop="2dp"
                  android:background="@android:color/darker_gray"
                  app:layout_constraintStart_toStartOf="parent"
                  app:layout_constraintEnd_toEndOf="parent"
                  app:layout_constraintTop_toBottomOf="@+id/btn_cerrar_sesion"/>
        </androidx.constraintlayout.widget.ConstraintLayout>

        <ImageButton
                android:id="@+id/btn_sync"
                android:src="@drawable/ic_sync_green"
                android:layout_width="55dp"
                android:layout_height="50dp"
                android:padding="4dp"
                app:layout_constraintTop_toBottomOf="@+id/constraintLayout"
                app:layout_constraintEnd_toEndOf="parent"
                android:onClick="sincronizar"
                android:background="@drawable/round_image_button"
                />

        <TextView
                android:text="@string/lista_de_incidencias_registradas"
                android:layout_width="wrap_content"
                android:fontFamily="sans-serif-light"
                android:layout_height="wrap_content"
                android:textSize="16sp"
                android:id="@+id/textView2"
                app:layout_constraintTop_toBottomOf="@+id/constraintLayout"
                app:layout_constraintStart_toStartOf="parent" android:layout_marginStart="16dp"
                android:layout_marginTop="8dp"/>

    </androidx.constraintlayout.widget.ConstraintLayout>
</layout>

in kotlin side:

            .on(this, btn_sync)
            .autoHide(true, 3000)
            .corner(30)
            .position(ViewTooltip.Position.LEFT)
            .text("Sincronizar")
            .show()

Here's an image with the problem result:
screenshot_20190102-151819_early alert

@Crone163
Copy link

Crone163 commented Feb 3, 2019

I found a way to manually setup the position like this

Do this after .show();

int x, y;
final Rect rect = new Rect();
mPalette.getGlobalVisibleRect(rect);
x = rect.left - mToolTipViewCreate.getWidth() - 10;
y = rect.top;
mToolTipViewCreate.setTranslationX(x);
mToolTipViewCreate.setTranslationY(y);

its working for ViewTooltip.Position.LEFT

@matkoniecz
Copy link

It seems to be regression. For me this problem appeared on attempt to upgrade to 1.2.0 from 1.1.0.

I am compiling StreetComplete - https://github.com/westnordost/StreetComplete/

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants