English 中文(简体)
如何使Icon在外线特区符合杰普勒斯提纲的顶端?
原标题:How to make leadingIcon in OutlinedTextField align to the top of the outline in Jetpack Compose?
  • 时间:2023-05-19 13:26:34
  •  标签:
  • textfield

OutlinedTextfield is great as it provides a preformatted textfield that looks graet and that you can twek to your needs. One of the features is a leading Icon the issue is that it will always center vertically (see bottom of picture) and I really want it in the top corner of the outline along with the hint enter image description here

问题回答

我认为我们不会直接改变领导伊科的严重性。 需要做一些工作。 为此,

var input by remember { mutableStateOf("") }
var isFocused by remember { mutableStateOf(false) }
Row(
    modifier = Modifier
        .border(
            width = if (isFocused) 2.dp else 1.dp,
            color = if (isFocused) Color.Gray else Color.Gray.copy(alpha = 0.8f),
            shape = RoundedCornerShape(5.dp)
        )
        .clip(RoundedCornerShape(5.dp))
        .height(120.dp)
        .fillMaxWidth()
 ) {
    Box(
       modifier = Modifier.defaultMinSize(48.dp, 48.dp),
       contentAlignment = Alignment.Center
    ) {
       Icon(
            imageVector = Icons.Default.Info,
            contentDescription = null
       )
    }
    BasicTextField(
         value = input,
         onValueChange = { input = it },
         modifier = Modifier
            .fillMaxWidth()
            .fillMaxHeight()
            .onFocusChanged { state ->
                isFocused = state.isFocused
            }
            .padding(top = 8.dp)
    )
 }

enter image description here

You can add more customization to BasicTextField.

这可能很晚,但我提出了一个解决办法。 Wrap the OutlinedTextArea in a Column that use Modifier.hala (IntrinsicSize.Min)。 * E/CN.6/2009/1。

* (可能将哥伦堡和Modifier.hala(IntrinsicSize.Min)直接并入提格雷拉。 我确实试图这样做,因为我需要其他东西。

其次,主角是一席之地。

Box( contentAlignment = Alignment.TopCenter,
    modifier = Modifier
        .fillMaxHeight() 
        .padding(top = 16.dp ) 
   ) {
      Icon( imageVector = ImageVector.vectorResource(iconRes))
     }

The .fillMaxHeight makes the Box take the size of the Column (or TextArea) and the padding pushes it down to where you d like it. I got the inspiration from this article.





相关问题
format text_field helper?

Is it possible to apply strftime formatting to the value of a text input field using a Rails text_field helper? In the form I use for creating or editing a record, I have a text input field which is ...

django admin TinyMCE integration

This is weird: I have installed and configured django-tinymce, but it doesn t seem to work with django admin. this works fine with Safari: class ArticleAdmin(admin.ModelAdmin): ...

TextField in UITableView

I m new to iphone world .. help me out of this. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { NSString *MYIdentifier =@"MyIdentifier"; ...

Static text within text field?

How can i keep static text within a <input type="text" name="site"> text field, just like the tumblr account ***.tumblr.com here > http://www.tumblr.com/

Select only first four lines, from Sql text field

Sql Server 2008 Express >> Visual Web Developer >> C# I m pulling records out of the table like this: SELECT Name, Category, Review FROM ReviewTable This works fine but the Review field Type in SQL ...

Flash Dynamic Text Width

Hey! I try to find out the text size of a textfield in the following example field.text = aaaaaaa ; trace(field.textWidth); setTimeput(function(){ field.text = aa ; trace(field.textWidth); },...

Textfield and Go Button

I would like to place search textfield and the Go button side by side. It looks aligned equally in Moz, Opera, IE8, Safari but not in IE7. IE7 shows 1px gap in height. How it can be done for IE7?

热门标签