简体   繁体   English

如何在 Android Studio 中使文本处于使用状态(颤振)

[英]How to make text be on top in use (Flutter) in Android Studio

so I want to make a simple text in a flutter framework, but I don't know to make the text for going on the top of the text, this is the example of the image I want to be on top:所以我想在 flutter 框架中制作一个简单的文本,但我不知道将文本放在文本的顶部,这是我想要放在顶部的图像示例:

图片

this is my DetailPage.dart:这是我的 DetailPage.dart:

 @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
          backgroundColor: Colors.redAccent,
          title: Text(
            'Detail ' + itemJudul,
            style: TextStyle(color: Colors.white),
          )),
      body: Column(

        mainAxisSize: MainAxisSize.min,
        mainAxisAlignment: MainAxisAlignment.start,
        children: <Widget>[
          Center(child: Image.asset(itemImage)),
          Text(
            itemJudul,
            style: TextStyle(color: Colors.redAccent, fontSize: 30.0),
          ),
          Text(itemSub),
          Text('Sisa Item =' + qty),
          Container(
            width: 200,
            child: Text("Bahan Bahan",
                textAlign: TextAlign.left,
                style: new TextStyle(fontWeight: FontWeight.bold) // has impact
                ),
            alignment: Alignment.centerLeft,
          ),
          Container(
            child: Text(
              listbahanan,
              textAlign: TextAlign.left,
            ),
            alignment: Alignment.centerLeft,
          ),
          Container(
            child: Text(
              listbahan2,
              textAlign: TextAlign.right,
            ),
            alignment: Alignment.center,
            padding: EdgeInsets.all(5),
          )
        ],
      ),
    );
  }

U can use two columns wrapped in a row.你可以使用包裹在一行中的两列。

Row(
  children: [
    Expanded(
      child: Container(
          child: Text(
            listbahanan,
            textAlign: TextAlign.left,
          ),
          alignment: Alignment.centerLeft,
       ),
    ),
    Expanded(
      child: Container(
        child: Text(
           listbahan2,
           textAlign: TextAlign.right,
        ),
        alignment: Alignment.center,
        padding: EdgeInsets.all(5),
     )
  ],
),

You need to use Row to align two lists side by side.您需要使用Row将两个列表并排对齐。 Also, I don't think it's a good idea to store a list as string, better use List for storing and ListView for displaying the list items.另外,我认为将列表存储为字符串不是一个好主意,最好使用List来存储和ListView来显示列表项。

@override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
          backgroundColor: Colors.redAccent,
          title: Text(
            'Detail ' + itemJudul,
            style: TextStyle(color: Colors.white),
          )),
      body: Column(

        mainAxisSize: MainAxisSize.min,
        mainAxisAlignment: MainAxisAlignment.start,
        children: <Widget>[
          Center(child: Image.asset(itemImage)),
          Text(
            itemJudul,
            style: TextStyle(color: Colors.redAccent, fontSize: 30.0),
          ),
          Text(itemSub),
          Text('Sisa Item =' + qty),
          Container(
            width: 200,
            child: Text("Bahan Bahan",
                textAlign: TextAlign.left,
                style: new TextStyle(fontWeight: FontWeight.bold) // has impact
            ),
            alignment: Alignment.centerLeft,
          ),
          Row( // this is new
            children: <Widget>[
              Flexible( // this is new
                child: Text(
                  listbahanan,
                  textAlign: TextAlign.left,
                ),
              ),
              Flexible( // this is new
                child: Text(
                  listbahan2,
                  textAlign: TextAlign.right,
                ),
              )
            ],
          ),
        ],
      ),
    );
  }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在Cardview Android Studio中制作运行文本? - How to make running text in cardview android studio? 如何使新插入的行成为ListView(Android Studio)的顶部 - How to make new inserted rows become on top of ListView (Android Studio) 如何使 android 工作室布局(XML)扩展到屏幕的最顶部 - How to make android studio layout (XML) extend to the very top of the screen 如何使 android 工作室同时调试 flutter 代码和 kotlin 代码 - how to make android studio debug both flutter code and kotlin code 如何使 android-studio 中的类使用相同的根布局但在 TextViews 上显示不同的文本 - How to make classes in android-studio to use the same root layout but with different text shown on TextViews 如何将纯文本中的文本设置为字符串(Android Studio) - How to make the text from a Plain Text a String(Android Studio) 如何在Android中创建文本字段以在Flutter应用中使用 - How to create Text Field in Android to use in a Flutter app 如何在 android 工作室中使按钮文本获得不同的方向 animation - How to make buttons text get different directions animation in android studio 如何使背景透明而不影响android studio中的文本 - how to make background transparent without affecting text in android studio 在android studio上按下按钮时如何进行简单的文本交换 - How to make simple text swap when button pressed on android studio
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM