Android 使用自定义形状编辑文本
Android edit text with custom shape
如何编辑这样的文字形状。
我的意思是右圆角和完全相同的形状。据我所知,9 补丁对我没有帮助。
9 补丁将是您情况的最佳方式,创建 9 补丁并将其设置为您的 EditText
.
的背景
我这里给大家一张样图,大家可以试一下
editText.setBackground(R.drawable.edt_bg);
这九个补丁会对你有所帮助。只需将此 ninepatch 图像应用为 editText
的背景
您必须为 EditText
创建背景图片。对于其他布局,您必须创建如下所示的布局。它不是确切的 xml 但向您展示了这个想法。
<RelativeLayout layout_width="match_parent" layout_height="50dp">
<EditText layout_width="wrap_content" layout_height="wrap_content"
android:background="@drawable/editTextBackground" layout_alignParentLeft="true" layout_marginLeft="10dp">
<ImageView layout_width="wrap_content" layout_height="wrap_content"
centerVertical="true" marginLeft="15dp"
android:background="@drawable/smily" />
<ImageView layout_width="wrap_content" layout_height="wrap_content"
centerVertical="true"
alignRight="@id/editTExt"
android:background="@drawable/camera" />
<ImageView layout_width="wrap_content" layout_height="wrap_content"
centerVertical="true" marginLeft="15dp"
alignParentRight="true"
android:background="@drawable/mic" />
</RelativeLayout>
希望这能给您带来灵感。
如何编辑这样的文字形状。
我的意思是右圆角和完全相同的形状。据我所知,9 补丁对我没有帮助。
9 补丁将是您情况的最佳方式,创建 9 补丁并将其设置为您的 EditText
.
我这里给大家一张样图,大家可以试一下
editText.setBackground(R.drawable.edt_bg);
这九个补丁会对你有所帮助。只需将此 ninepatch 图像应用为 editText
的背景您必须为 EditText
创建背景图片。对于其他布局,您必须创建如下所示的布局。它不是确切的 xml 但向您展示了这个想法。
<RelativeLayout layout_width="match_parent" layout_height="50dp">
<EditText layout_width="wrap_content" layout_height="wrap_content"
android:background="@drawable/editTextBackground" layout_alignParentLeft="true" layout_marginLeft="10dp">
<ImageView layout_width="wrap_content" layout_height="wrap_content"
centerVertical="true" marginLeft="15dp"
android:background="@drawable/smily" />
<ImageView layout_width="wrap_content" layout_height="wrap_content"
centerVertical="true"
alignRight="@id/editTExt"
android:background="@drawable/camera" />
<ImageView layout_width="wrap_content" layout_height="wrap_content"
centerVertical="true" marginLeft="15dp"
alignParentRight="true"
android:background="@drawable/mic" />
</RelativeLayout>
希望这能给您带来灵感。