明確にするために、親のlinearLayoutが480dpの場合、テキストビューを80 dpの位置に中央に配置する必要があります。テキストビューの幅が10 dpの場合、スペースとして75 dpから85 dpが必要です。これを行うにはどうすればよいですか?
2 に答える
0
を使用して親のTextView
半分の幅を指定しlayout_weight
、 でテキストを中央に配置できますandroid:gravity
。
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center" />
<View
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
</LinearLayout>
于 2013-06-08T04:41:49.490 に答える