Android 4.0〜4.2 でTextViewの singleLine とか maxLines を設定するとテキストや背景がずれて、テキストが上寄りに見える
ボタンのテキストが上に寄っているマヌケなアプリを見かける理由はフォントの問題だと思っていたけど、違っていたみたい。
singleLine=true とか maxLines で行数を指定すると、テキストや background の位置がずれて困る。
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" tools:context=".MainActivity" > <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="LinearLayoutで横に並べる \n(右がsingleLine=true)" /> <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="#8ff" > <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="あうあ" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:singleLine="true" android:text="あうあ" /> </LinearLayout> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="RelativeLayoutで横に並べる" /> <RelativeLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="#ff8" > <Button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="あうあ" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_toRightOf="@+id/button1" android:singleLine="true" android:text="あうあ" /> </RelativeLayout> </LinearLayout>
わけがわからない...。