【问题标题】:Android edit text with custom shapeAndroid 使用自定义形状编辑文本
【发布时间】:2016-01-21 09:54:51
【问题描述】:

我怎样才能像这样编辑文本形状。

我的意思是右圆角和完全相同的形状。据我了解,9 补丁对我没有帮助。

【问题讨论】:

    标签: android android-edittext android-shape


    【解决方案1】:

    9 补丁将是您的最佳方式,创建 9 补丁并将其设置为您的 EditText 的背景。

    这里我给你样张,你可以试试。

    editText.setBackground(R.drawable.edt_bg);
    

    【讨论】:

      【解决方案2】:

      这九个补丁会帮助你。只需将此九块图像应用为editText的背景

      【讨论】:

        【解决方案3】:

        您必须为您的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>
        

        希望这能给你一些想法。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2020-06-22
          • 2023-03-23
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2015-05-18
          相关资源
          最近更新 更多