Как правильно Выровнять изображение на панели инструментов в Android

Я бы сделал это с библиотекой SMTPJs . Он предлагает шифрование для ваших учетных данных, таких как имя пользователя, пароль и т. д.

16
задан Pehlaj 28 September 2017 в 05:12
поделиться

1 ответ

Принятый ответ только работает, если layout_width="match_parent", но это действие также омрачает/скрывает заголовок панели инструментов. Единственный путь к [1 116] шоу и Изображение и заголовок Панели инструментов при наличии ширины относительного расположения как фиксированная длина и , который не является идеален для большинства людей. Даже тогда относительное расположение не выравнивается к праву .

Мое Обходное решение
Имеет относительную ширину расположения как layout_width="match_parent" (Это скрывает заголовок панели инструментов), и затем добавьте плоскость textview в нем с alignParentStart="true"
Тогда в основном виде деятельности, замените toolbar.setTitle("my_title"), с textView.setText("my_title")

т.е.

<androidx.appcompat.widget.Toolbar android:id="@+id/toolbar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@color/colorPrimary"
    android:minHeight="?attr/actionBarSize"
    android:theme="@style/AppTheme.AppBarOverlay"
    app:popupTheme="@style/AppTheme.PopupOverlay">
    <RelativeLayout android:id="@+id/toolbar_item_container"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <!--The Title Bar -->
        <TextView android:id="@+id/title_bar"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            style="@style/heading"
            android:textColor="@color/white"
            android:layout_alignParentStart="true" />

        <!--The Inbox-->
        <RelativeLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:clickable="true"
            android:focusable="true"
            android:foreground="?android:attr/selectableItemBackground"
            android:layout_marginEnd="@dimen/layout_margin"
            android:layout_toLeftOf="@+id/switchhouse_panel">
            <ImageView android:id="@+id/house_admin_messages"
                android:layout_width="25dp"
                android:layout_height="25dp"
                android:cropToPadding="true"
                android:scaleType="centerCrop"
                app:srcCompat="@drawable/ic_email_white_24dp"
                android:layout_alignParentTop="true"/>
            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="20dp"
                android:background="@drawable/circle_custom"
                android:backgroundTint="@color/green"
                android:cropToPadding="true"
                android:layout_marginStart="20dp"/>
        </RelativeLayout>

        <!--The Switch-->
        <RelativeLayout android:id="@+id/switchhouse_panel"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:clickable="true"
            android:focusable="true"
            android:foreground="?android:attr/selectableItemBackground"
            android:layout_marginStart="@dimen/layout_margin"
            android:layout_alignParentRight="true">
            <ImageView android:id="@+id/house_cover_thumbnail"
                android:layout_width="30dp"
                android:layout_height="30dp"
                android:background="@drawable/circle_custom"
                android:cropToPadding="true"
                android:scaleType="centerCrop"
                android:layout_alignParentTop="true"/>
            <ImageView
                android:layout_width="20dp"
                android:layout_height="20dp"
                android:background="@drawable/circle_custom"
                android:padding="3dp"
                app:srcCompat="@drawable/ic_cached_black_24dp"
                android:cropToPadding="true"
                android:layout_marginStart="20dp"/>
        </RelativeLayout>
    </RelativeLayout>
</androidx.appcompat.widget.Toolbar>

В Основном виде деятельности

TextView title_bar = findViewById(R.id.title_bar);
title_bar.setText("Manage Property");

The Result

0
ответ дан Lefty 23 October 2019 в 07:45
поделиться
Другие вопросы по тегам:

Похожие вопросы: