簡體   English   中英

Android Studio 中可繪制開始的圖標位置問題

[英]Icon location problem with drawable Start in Android Studio

我有一個editetext並且我使用了drawable start,但是在執行過程中圖標不在正確的位置

Android Studio內部視圖

運行程序

首先我放了一個滾動視圖,然后是一個LinearLayout,里面是一個ConstraintLayout,然后是editText。

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context=".Activity.Activityy.MainActivity">

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:layout_editor_absoluteX="0dp"
        tools:layout_editor_absoluteY="0dp">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <androidx.constraintlayout.widget.ConstraintLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content">

                <TextView
                    android:id="@+id/textView"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginStart="32dp"
                    android:layout_marginTop="32dp"
                    android:text="Hi Rechard"
                    android:textColor="#FF6D00"
                    android:textSize="20sp"
                    android:textStyle="bold"
                    app:layout_constraintStart_toStartOf="parent"
                    app:layout_constraintTop_toTopOf="parent" />

                <TextView
                    android:id="@+id/textView2"
                    android:layout_width="wrap_content"
                    android:layout_height="27dp"
                    android:layout_marginTop="8dp"
                    android:text="@string/order_eat"
                    android:textSize="20sp"
                    android:textStyle="bold"
                    app:layout_constraintStart_toStartOf="@+id/textView"
                    app:layout_constraintTop_toBottomOf="@+id/textView" />

                <ImageView
                    android:id="@+id/imageView3"
                    android:layout_width="82dp"
                    android:layout_height="78dp"
                    android:layout_marginEnd="32dp"
                    android:src="@drawable/_f5736be590fe78e73bc4e4d7c012dda"
                    app:layout_constraintBottom_toBottomOf="@+id/textView2"
                    app:layout_constraintEnd_toEndOf="parent"
                    app:layout_constraintTop_toTopOf="@+id/textView" />

                <EditText
                    android:id="@+id/editTextTextPersonName"
                    android:layout_width="315dp"
                    android:layout_height="68dp"
                    android:layout_marginStart="8dp"
                    android:layout_marginTop="15dp"
                    android:layout_marginEnd="8dp"
                    android:background="@drawable/search_background"
                    android:drawableStart="@drawable/icons8_search_32"
                    android:drawablePadding="10dp"
                    android:ems="10"
                    android:hint="Find Your Food"
                    android:inputType="textPersonName"
                    android:textStyle="italic"
                    app:layout_constraintEnd_toEndOf="parent"
                    app:layout_constraintStart_toStartOf="parent"
                    app:layout_constraintTop_toBottomOf="@+id/textView2" />
            </androidx.constraintlayout.widget.ConstraintLayout>

        </LinearLayout>
    </ScrollView>

</androidx.constraintlayout.widget.ConstraintLayout>

在執行過程中,文本也移到了右側,而它們位於設計的左側。

在 android 中start表示leftend表示right

您必須使用android:drawableEnd="ICON"而不是android:drawableStart="ICON"來設置圖標右側。

我手機的語言是正確的,但是我的設計是左邊的,所以當我運行時,它會自動指向右邊 經過大量研究,我能夠解決我的問題只需 go 到清單文件並制作以下行

android:supportsRtl="true"

android:supportsRtl="false"

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM