android之使用可编辑和不可编辑的提示/文本编辑文本之Android

发布时间 2023-12-05 17:18:57作者: 勇士的黎明

请您参考如下方法:

 

整个东西不是编辑文本,而是布局。您可以按如下方式实现该效果。

 

Java
<LinearLayout  
    android:id="@+id/container" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="horizontal" 
    android:background="@drawable/round_border"> 
    <TextView  
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="$" 
        android:padding="5dp"/> 
 
    <EditText  
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:background="@android:color/transparent" 
        android:hint="Enter your amount" 
        android:padding="5dp"/> 
</LinearLayout> 

@drawable/round_border is a drawable you should keep in drawable folder

Java
<?xml version="1.0" encoding="utf-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android" 
android:shape="rectangle" > 
 
<corners android:radius="5dp"/> 
<solid android:color="@android:color/holo_orange_light"/> 
 
</shape>