有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java如何在安卓中创建方形文本框

我必须创建一个activity,其中应该包含一个方形文本框,用户可以在其中编写注释并通过单击按钮进行保存

示例活动附于此处:

enter image description here

我已经做了足够多的研究,我发现最多的是创建自定义TextView,因为我可以在一行中输入文本,但我需要在输入本身的同时创建下一行

有人能帮我完成这项任务吗


共 (1) 个答案

  1. # 1 楼答案

    试试这个

     <EditText
      android:background="@drawable/custom_button"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:hint="text6 demo" />
    

    在你的drawble文件夹中创建这样的背景

     <?xml version="1.0" encoding="utf-8"?>
    <selector xmlns:android="http://schemas.android.com/apk/res/android">
        <item>
            <shape android:shape="rectangle">
                <stroke android:width="2dp" android:color="@color/colorPrimary" />
    
            </shape>
        </item>
    </selector>