私は、ユーザー名とパスワードのフィールドを追加するログインページがあるAndroidプロジェクトに取り組んでいます。私が持っているデザインは、この半透明の方法で、イメージを内部に入れておく必要があります。どのようなアイデアを私はそれを半透明にし、それを形にするためにEditTextを変えることができますか、それを透明にするために背景をnullまたは色などで設定しますが、これは何も見つかりませんでした。Android:画像が入った半透明の編集テキストを作成
デザイン:
私は相対的なレイアウトを使用して、右側のこれらのアイコン午前、私は別のPNGファイルでそれらを持っています。私はEdittextの中に直接それらを追加することができますが、私は、ユーザー名とパスワードが長いと、画像の上に行くことを心配しています。そのための戦略はありますか?ありがとうございました。
コード:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:background="@drawable/background"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Text"
android:id="@+id/textView"
android:textSize="32sp"
android:textColor="@color/common_signin_btn_dark_text_default"
android:layout_marginTop="75dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/editText"
android:layout_below="@+id/textView"
android:layout_marginTop="41dp"
android:layout_alignRight="@+id/textView"
android:layout_alignEnd="@+id/textView"
android:layout_alignLeft="@+id/textView"
android:layout_alignStart="@+id/textView" />
</RelativeLayout>
更新スクリーンショットのEditText
<EditText
android:layout_width="wrap_content"
android:layout_height="45dp"
android:id="@+id/emailEditText"
android:inputType="textEmailAddress"
android:layout_below="@+id/textView"
android:layout_marginTop="41dp"
android:drawableEnd="@drawable/Mail"
android:drawableRight="@drawable/Mail"
android:maxLines="1"
android:ellipsize="end"
android:hint="Email"
android:textColorHint="@color/common_signin_btn_dark_text_focused"
android:background="@drawable/layout_bg"
android:layout_alignRight="@+id/textView"
android:layout_alignEnd="@+id/textView"
android:layout_alignLeft="@+id/textView"
android:layout_alignStart="@+id/textView" >
</EditText>
layout_bg.x更新
ミリリットル:
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/traslucent_background" />
<stroke android:width="1dip" android:color="#B1BCBE" />
<corners android:radius="17dip"/>
<padding android:left="0dip" android:top="0dip" android:right="0dip" android:bottom="0dip" />
</shape>
これはうまくいきます。 2番目の問題の戦略を教えてください。右側のユーザー名とパスワードのアイコンではテキストが書かれません。 –
この属性(drawableEnd/Right)で心配する必要はありません。テキストは画像の直前で停止します(さらに、drawablePaddingを追加してテキストとアイコンの間のギャルを広げることができます) – josemigallas
これは素晴らしいアイコンが大きすぎます。どのように位置とサイズを微調整できますか? –