2
我不明白爲什麼我需要做的是讓我的視圖在TableLayout中完美對齊。爲什麼這些意見不一致?
我有一個類似的佈局:
<TableLayout android:id="@+id/keyboard"
android:layout_width="fill_parent"
android:layout_height="378px">
<TableRow android:layout_span="5" >
<TextView android:id="@+id/button20"
android:layout_width="63px"
android:layout_height="42px"
android:textSize="10"
android:text="L1" />
<TextView android:id="@+id/button21"
android:layout_width="63px"
android:layout_height="42px"
android:textSize="12"
android:text="L2" />
<TextView android:id="@+id/button22"
android:layout_width="63px"
android:layout_height="42px"
android:textSize="12"
android:text="L3" />
<TextView android:id="@+id/button23"
android:layout_width="63px"
android:layout_height="42px"
android:textSize="12"
android:text="L4" />
<TextView android:id="@+id/button24"
android:layout_width="63px"
android:layout_height="42px"
android:textSize="12"
android:text="L5" />
</TableRow>
</TableLayout>
現在,當畫,第一TextView的顯示2個像素下比所有其他的人。 覆蓋onLayout方法;我看到onLayout被稱爲第一個查看: top = 2;底部= 44;而所有其他的都是top = 0;底部= 42.
只要字體大小與其他字體大小不同,就會發生這種情況;或者如果文本換行在另一行(因爲它不符合寬度)。 所有TextView具有相同的尺寸;但有些顯示比另一個略低。
這種佈局是一個RelativeLayout的範圍內,如果有差別。
我嘗試了很多不同的組合,而且總是有一些差異發生。 任何幫助將不勝感激。
謝謝! JY
謝謝你,謝謝你,謝謝你...太專注於每個視圖的大小比我以前沒有注意到的是,文本的基線對齊所有從...時間 – jyavenard 2010-11-04 23:35:57
古答案自古以來,但仍有關! – 2016-01-26 20:13:52