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)並且文本應該與「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內聯?
只需從您的佈局中刪除此android:orientation =「vertical」行。 –