我想将 TextView
中的文本与其正下方的 EditText
中的文本对齐。如果不使用填充技巧,这可能吗?
如果不是,是不是被气馁了?我可以看到它被劝阻,因为它可能会使用户感到困惑,从而忽略两个控件之间的区别。
这是创建上述屏幕截图的布局:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:id="@+id/text_view"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:text="Please align my first character" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/text_view"
android:hint="To my first character" />
</RelativeLayout>
最佳答案
不,如果不使用填充或 layout_margin
,您将无法做到这一点。 EditText
有一个带边框和填充的背景,所以它的内容区域比 TextView
的区域小一点。我认为在这种情况下使用填充是正常的。
关于android - 将 TextView 左对齐到 EditText 中的文本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12644347/