在下面的截图中,我试图让蓝色框中的文本居中对齐。它太低了,需要上移一两个像素。我一直在调整填充,但似乎没有任何效果。
布局XML在此处:
布局XML在此处:
<RelativeLayout xmlns:tools="http://schemas.android.com/tools"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginRight="5dp"
xmlns:android="http://schemas.android.com/apk/res/android">
<TextView android:id="@+id/tvName"
android:layout_width="60dp"
android:layout_height="20dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="3dp"
android:background="@drawable/rectanglesegment"
android:gravity="center"
android:paddingBottom="2dp"
android:text="XXX" android:textSize="16sp"
android:textAppearance="?android:attr/textAppearanceMedium"/>
有什么建议吗?
@Snicolas 的反馈后,我现在有以下内容:
采用这种布局。
<TextView android:id="@+id/tvName"
android:layout_width="60dp"
android:layout_height="fill_parent"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="2dp"
android:layout_marginBottom="2dp"
android:background="@drawable/rectanglesegment"
android:gravity="center"
android:text="abv" android:textSize="16sp"
android:textAppearance="?android:attr/textAppearanceMedium"/>
android:gravity="center"
... - quietmint