【问题标题】:how to write on border of edit text如何在编辑文本的边框上书写
【发布时间】:2012-03-20 18:09:31
【问题描述】:

我需要创建一个编辑文本,其中包含一些与该文本框相关的文本。怎么做。虽然有一些方法可以通过 HTML。但我不知道如何在android中做到这一点。任何机构都可以为此建议我一些东西。为了清晰起见,我提供了我的要求的示例照片。

任何帮助将不胜感激

.....

【问题讨论】:

  • 没有帮助,链接将我带到除了 developer.android 之外的其他地方。而且他们建议使用 9 个补丁图像,这意味着在一个图像中进行。但我需要在不同的地方做。所以对我的问题有任何建议......
  • 我认为你可以扩展EditText并覆盖draw方法,如果只是一个边框,它会很容易绘制。但你也可以像上图那样画。
  • 我不太懂draw,所以我可以把它当作通用的。我的意思是,一旦声明,我可以在边框上有不同文本的任何地方使用它???????????

标签: android android-edittext


【解决方案1】:

你可以通过这种方式实现类似的目标,

    <RelativeLayout android:layout_width="fill_parent"
        android:id="@+id/myLayout1" android:layout_height="wrap_content">

        <EditText android:text="EditText" android:id="@+id/editText1" android:layout_marginTop="5dp" 
        android:layout_width="fill_parent" android:layout_height="wrap_content">
        </EditText>

        <TextView android:text="TextView" android:id="@+id/textView3" android:layout_marginLeft="10dp" android:textColor="#000000" android:background="#FFFFFF"
        android:layout_width="wrap_content" android:layout_height="wrap_content">
        </TextView>

    </RelativeLayout>

【讨论】:

  • 为此我爱你。为什么我不能多次投票给你。非常感谢
【解决方案2】:

我认为使用android:hint 也有助于放置一些与编辑文本相关的文本

但是,它只会在编辑文本为空并且在编辑文本内时才会显示文本,但不会像您在此处显示的那样。

我认为您在此处显示的布局可能需要更多时间来实现。

【讨论】:

  • 不,我需要它始终可见,所以我不能使用它。还是谢谢
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2013-10-10
  • 2011-06-16
  • 1970-01-01
  • 2012-03-14
  • 1970-01-01
  • 1970-01-01
  • 2012-02-29
相关资源
最近更新 更多