【问题标题】:How to draw lines in Android Edit Text?如何在 Android Edit Text 中画线?
【发布时间】:2011-07-20 10:00:09
【问题描述】:

我正在尝试构建一个记事本应用程序。我想在我的应用程序的编辑文本视图中有行,这是一个多行编辑文本。请让我知道如何做到这一点。感谢您的宝贵时间和建议。

【问题讨论】:

    标签: android android-layout android-edittext


    【解决方案1】:

    看看这个。notepad

    【讨论】:

      【解决方案2】:

      我认为您最好只显示背景,而不是“画线”。使用 View 的默认背景:

      http://developer.android.com/reference/android/view/View.html#setBackgroundResource(int)

      【讨论】:

        【解决方案3】:

        由于记事本的大小会根据手机屏幕的大小而有所不同,因此一个不错的选择是创建一个具有指定大小的画布,并在画布上以恒定的间隔水平绘制一条线。然后将canvas转换为drawable,并将editText的backgrounddrawable设置为drawable。

        【讨论】:

          【解决方案4】:

          你可以在resxml文件夹中拥有此代码

              <?xml version="1.0" encoding="utf-8"?>
          
          <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="line">
              <stroke android:width="1dp" android:color="#FF000000"
                      />
                      <padding android:bottom="20dip" />
          </shape>
          

          并将其包含在setBackgroundResource()

          【讨论】:

            猜你喜欢
            • 2022-01-10
            • 1970-01-01
            • 2017-01-01
            • 2018-05-14
            • 2012-12-11
            • 1970-01-01
            • 2020-10-24
            • 1970-01-01
            • 1970-01-01
            相关资源
            最近更新 更多