Questions tagged «layout-gravity»

5
Android-在LinearLayout中水平居中放置TextView
我有以下基本布局 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <LinearLayout android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="@drawable/title_bar_background"> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:textAppearance="?android:attr/textAppearanceLarge" android:padding="10dp" android:text="HELLO WORLD" /> </LinearLayout> <LinearLayout> 看起来xml是正确的,但文本在左侧对齐。textview占据了父级的整个宽度,并且将textview设置为居中。不确定是什么问题...

2
垂直内容在Android EditText中对齐
我有多行EditText: <EditText android:layout_gravity="center" android:id="@+id/txtMessage" android:layout_height="wrap_content" android:layout_below="@+id/lblMessage" android:layout_width="wrap_content" android:width="250dip" android:text="" android:maxLength="760" android:lines="4"> </EditText> 现在,内容与中间对齐。我想使内容与顶部对齐。 有做这件事的财产吗?
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.