HarmonyOS TextInput clearButton 位置问题

TextInput 的clearButton 距离TextInput 的右边间距无法控制。

HarmonyOS
2024-11-28 10:13:40
浏览
收藏 0
回答 1
待解决
回答 1
按赞同
/
按时间
zbw_apple

目前textInput的cancelButton暂时不支持调整间距此场景可以通过自定义组件实现,以下是参考Demo。

@Entry 
@Component 
struct TextInputExample { 
  @State text: string = '' 
  @State changeType:InputType = InputType.Number 
  controller: TextInputController = new TextInputController() 
  build() { 
    Column() { 
      Flex({direction: FlexDirection.Row}){ 
        Stack(){ 
          TextInput({ text: this.text, controller: this.controller }) 
            .type(this.changeType) 
            .placeholderFont({ size: 16, weight: 400 }) 
            .width('100%') 
            .height(56) 
            .onChange((value: string) => { this.text = value }) 
          Image($r('app.media.startIcon')) 
            .margin({ left: 290 }) 
            .width(20) 
            .height(20) 
            .onClick(() =>{ 
              this.text = '' 
            }) 
        } 
      } 
    }.width('100%').height('100%').backgroundColor('#F1F3F5') } }
分享
微博
QQ
微信
回复
2024-11-28 15:01:49
相关问题
HarmonyOS TextInput问题
109浏览 • 1回复 待解决
设置TextInput组件光标位置在起点
750浏览 • 1回复 待解决
HarmonyOS TextInput焦点问题
576浏览 • 1回复 待解决
HarmonyOS TextInput 换行问题
961浏览 • 1回复 待解决
HarmonyOS TextInput 组件问题
656浏览 • 1回复 待解决
HarmonyOS CustomDialog位置问题
443浏览 • 1回复 待解决
HarmonyOS Tabs位置问题
69浏览 • 1回复 待解决
HarmonyOS TextInput组件错误样式问题
762浏览 • 1回复 待解决
HarmonyOS textinput键盘弹出问题
419浏览 • 1回复 待解决
HarmonyOS TextInput自动获取焦点问题
304浏览 • 1回复 待解决
HarmonyOS ListItem位置指定问题
44浏览 • 1回复 待解决
HarmonyOS TextInput和键盘相关问题咨询
798浏览 • 1回复 待解决
HarmonyOS TextInput调用系统键盘问题
450浏览 • 1回复 待解决
HarmonyOS listitem位置保持的问题
165浏览 • 1回复 待解决
HarmonyOS 系统位置服务问题
470浏览 • 1回复 待解决
HarmonyOS RichEditor光标位置异常问题
291浏览 • 1回复 待解决
HarmonyOS TextInput自定义键盘问题
916浏览 • 1回复 待解决
HarmonyOS申请用户位置权限问题
742浏览 • 1回复 待解决
HarmonyOS TextInput绑定自定义键盘问题
824浏览 • 1回复 待解决
HarmonyOS 位置权限变更监听回调问题
416浏览 • 1回复 待解决