
我有一个ListVIEw与自定义适配器和此列表中的项目的布局.项目的布局只是带有ImageVIEw的TextVIEw.图像应与屏幕右侧对齐.但是,图像的位置会稍微移动,具体取决于TextVIEw中文本的长度.这就是它的样子:
这是我的XML代码:
<linearLayout xmlns:androID="http://schemas.androID.com/apk/res/androID" androID:layout_wIDth="match_parent" androID:layout_height="match_parent" androID:orIEntation="horizontal" androID:gravity="center_vertical" > <TextVIEw androID:ID="@+ID/txtcategoryname" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:layout_weight="10" androID:singleline="true" androID:ellipsize="end" androID:gravity="center_vertical" androID:paddingtop="5dp" androID:paddingBottom="5dp" androID:textcolor="@color/List_text_color" androID:textAppearance="?androID:attr/textAppearanceLarge" /> <ImageVIEw androID:ID="@+ID/imgArrowRight" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:layout_weight="1" androID:src="@drawable/right_arrow_44" androID:contentDescription="@string/img_description_right_arrow" androID:layout_gravity="right" /></linearLayout>如何使图像始终与右侧对齐,而不是轻推?
解决方法:
RelativeLayout应该使用androID:layout_alignParentRight和androID:layout_alignParentleft很好地解决你的问题.就像是:
<relativeLayout xmlns:androID="http://schemas.androID.com/apk/res/androID" androID:layout_wIDth="match_parent" androID:layout_height="match_parent"><TextVIEw androID:ID="@+ID/txtcategoryname" androID:layout_alignParentleft="true" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:singleline="true" androID:ellipsize="end" androID:gravity="center_vertical" androID:paddingtop="5dp" androID:paddingBottom="5dp" androID:textcolor="@color/List_text_color" androID:textAppearance="?androID:attr/textAppearanceLarge" /><ImageVIEw androID:ID="@+ID/imgArrowRight" androID:layout_alignParentRight="true" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:src="@drawable/right_arrow_44" androID:contentDescription="@string/img_description_right_arrow"/> 总结 以上是内存溢出为你收集整理的android – 在LinearLayout中对齐TextView和ImageView全部内容,希望文章能够帮你解决android – 在LinearLayout中对齐TextView和ImageView所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)