TextView和ImageView在LinearLayout中的位置
我如何使 TextView 的位置位于 LinearLayout 的左侧,而 ImageView 的位置位于 LinearLayout 的右侧,
<LinearLayout
android:orientation="horizontal"
android:layout_gravity="center_horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="1dip"
android:layout_marginRight="5dip"
android:layout_marginLeft="5dip"
>
<TextView
android:id="@+id/formulaTextKite"
android:text="@string/formulasAreasKite"
style="@style/stripFormulasTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<ImageView
android:id="@+id/picAreaKite"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="2dip"
android:layout_marginLeft="2dip"
android:src="@drawable/areakite"
/>
</LinearLayout>
谢谢 伊齐克
how do i make the position of TextView in the left of LinearLayout and ImageView in the right of LinearLayout
<LinearLayout
android:orientation="horizontal"
android:layout_gravity="center_horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="1dip"
android:layout_marginRight="5dip"
android:layout_marginLeft="5dip"
>
<TextView
android:id="@+id/formulaTextKite"
android:text="@string/formulasAreasKite"
style="@style/stripFormulasTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<ImageView
android:id="@+id/picAreaKite"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="2dip"
android:layout_marginLeft="2dip"
android:src="@drawable/areakite"
/>
</LinearLayout>
thanks
Itzik
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
最好使用像这样的RelativeLayout,
Its better to use RelativeLayout Like this,
试试这个,
Try This,
您可以将layout_gravity
用于textView,使用layout_gravity =“left”
,对于imageView使用layout_gravity =“right”
,并且还可以将线性布局方向设置为vertical,这样才能正常工作。
HTH。
you could use layout_gravity
for textView use layout_gravity = "left"
and for imageView use layout_gravity = "right"
and also make your linear layout orientation vertical , for this to work.
HTH.
我使用了以下 xml 安排并且它有效:
I used the Following xml arrangement and it worked: