首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在安卓中显示两个TextView一个(键)一个(值)?

如何在安卓中显示两个TextView一个(键)一个(值)?
EN

Stack Overflow用户
提问于 2017-02-22 04:33:29
回答 3查看 295关注 0票数 0

谁能帮我一个接一个地设计两个TextViews,像问答。

例如:信号强度=卓越。请看附件图片。

EN

回答 3

Stack Overflow用户

发布于 2017-02-22 04:37:20

https://developer.android.com/reference/android/widget/LinearLayout.html

代码语言:javascript
复制
<LinearLayout
   android:width="match_parent"
   android:height="wrap_content"
   android:orientation="vertical">

   <TextView
       android:width="match_parent"
       android:height="wrap_content"
       android:text="signal strength"/>

   <TextView
       android:width="match_parent"
       android:height="wrap_content"
       android:text="Excellent"/>

</LinearLayout>
票数 0
EN

Stack Overflow用户

发布于 2017-02-22 04:38:57

只需在可扩展标记语言中使用2个TextView对象,并根据您的设计设置它们的样式。可以使用android:textStyleandroid:textSize属性设置TextViews的样式。

然后,您的将需要在相应的dialog类中调用 setText()方法,以在value TextView中显示结果。例如:

代码语言:javascript
复制
<TextView
    android:id="@+id/keyTextView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:layout_alignParentTop="true"
    android:layout_marginTop="5dp"
    android:text="Signal Strength"
    android:textSize="15sp" />

<TextView
    android:id="@+id/valueTextView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/keyTextView"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:text="Excellent"
    android:textColor="@android:color/black"
    android:textSize="16sp"
    android:textStyle="bold" />
票数 0
EN

Stack Overflow用户

发布于 2017-02-22 04:42:10

您可以使用TextInputLayout

代码语言:javascript
复制
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">

        <EditText 
            android:textStyle="bold"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Excellent"
            android:inputType="none"
            android:hint="Signal Strength" />

</android.support.design.widget.TextInputLayout>

我想这会对你有帮助的。

如果有任何疑问,请让我知道

祝你编码愉快。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/42377404

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档