不能够调整在Android上的同一行两个文本的意见 [英] not able to align two text views on the same line in android

查看:115
本文介绍了不能够调整在Android上的同一行两个文本的意见的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

XML文件,

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:orientation="vertical"  
  android:id="@+id/profileLayout">

  <TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Super Powers"  
    />
</LinearLayout>

在活动的文件,我想添加一个文本费尔德,其价值会动态变化(值将是ON或OFF),而该文本应该是内嵌超级大国

and in Activity file i am trying to add one text feild whose value will change dynamically (value will be either ON or OFF) and that text should be inline with "Super Powers"

TextView valueTV = new TextView(this);
valueTV.setText("OFF");
valueTV.setId(5);
valueTV.setGravity(Gravity.RIGHT);
valueTV.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT));

((LinearLayout) linearLayout).addView(valueTV);

有谁能够告诉我如何做两个textViews内联?

can anybody tell me how to make two textViews inline?

推荐答案

您的LinearLayout具有垂直方向。它应是水平的,以便能够将其子在同一行中。

Your LinearLayout has vertical orientation. It should be horizontal to be able to place its children in the same line.

这篇关于不能够调整在Android上的同一行两个文本的意见的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆