我是 android 开发的初学者,这是我的代码(它是相对布局)
<ImageView
android:id="@+id/logo1"
android:layout_width="50dp"
android:layout_height="50dp"
android:src="@drawable/telephone1"
android:layout_marginTop="10dp"
android:layout_below="@id/text4"/>
<TextView
android:id="@+id/text5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="00966-13-8420444"
android:fontFamily="sans-serif"
android:textSize="20sp"
android:layout_toRightOf="@id/logo1"
/>
我认为 android:layout_toRightOf="@id/logo1 就足够了 并且文本位于图像的右侧(正确对齐)但它出现在设备的顶部(图像位于底部但不在底部边缘),我应该添加哪一行代码?
对不起英语。 谢谢
最佳答案
如果我对你的问题的理解正确,你希望你的文字在图片之外,但与图片中心对齐,试试这个:
<ImageView
android:id="@+id/logo1"
android:layout_width="50dp"
android:layout_height="50dp"
android:src="@drawable/telephone1"
android:layout_marginTop="10dp"
android:layout_below="@id/text4"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_gravity="center_vertical">
<TextView
android:id="@+id/text5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="00966-13-8420444"
android:fontFamily="sans-serif"
android:textSize="20sp"
android:layout_toRightOf="@id/logo1"/>
</LinearLayout>
关于android - 如何将 TextView 对齐到 ImageView 的右侧,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38059647/