如何将1600px 1600px的图像安装到EditText作为android:background
我正在尝试在如何将1600px 1600px的图像安装到EditText作为android:background,android,xml,android-studio,Android,Xml,Android Studio,我正在尝试在EditText中安装一个1600px 1600px的图像。 我尝试了很多android:padding的组合,但似乎都不起作用 这是我的目标: 有没有办法在这个特定的XML中这样做,或者我必须更改图像的分辨率?注意: 要实现目标,应使用EditText而不是ImageView。 (您必须在.xml中添加EditText) 以下是实现目标的方法 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xml
EditText
中安装一个1600px 1600px的图像。
我尝试了很多android:padding的组合,但似乎都不起作用
这是我的目标:
有没有办法在这个特定的XML中这样做,或者我必须更改图像的分辨率?注意:
要实现目标,应使用EditText而不是ImageView。
(您必须在.xml中添加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:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="26dp"
android:background="#3F4650"
android:drawableLeft="@drawable/ic_person"
android:hint="Username"
android:textSize="28dp"
android:textColorHint="#636A72"
/>
</RelativeLayout>
在app>res>drawable>ic_person.xml中为EditText中的人物图像创建xml文件或您也可以使用不同的图像,只需更改android:drawableLeft=“@drawable/your_other_image”
我建议你以家长的身份进行线性布局。使重力:水平,并添加ImageView和EditText
比如:
<LinearLayout>
<ImageView/>
<EditText/>
</LinearLayout>
使ImageView
的宽度与LinearLayout
的高度相匹配,以获得方形,您应该都已设置好
祝你好运 您的编辑文本在哪里?
<LinearLayout>
<ImageView/>
<EditText/>
</LinearLayout>