android – 使相对布局中的两个文本视图占据高度的50%

android – 使相对布局中的两个文本视图占据高度的50%,第1张

概述我有一个自定义列表视图,其中包含以下项目布局: <?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_heig 我有一个自定义列表视图,其中包含以下项目布局:

<?xml version="1.0" enCoding="utf-8"?><relativeLayout xmlns:androID="http://schemas.androID.com/apk/res/androID"    androID:layout_wIDth="fill_parent"    androID:layout_height="?androID:attr/ListPreferredItemHeight"    androID:paddingBottom="2dip"    androID:paddingtop="2dip" >    <ImageVIEw        androID:ID="@+ID/icon"        androID:layout_wIDth="wrap_content"        androID:layout_height="wrap_content"        androID:layout_alignParentBottom="true"        androID:layout_alignParenttop="true"        androID:paddingleft="6dip" />    <TextVIEw        androID:ID="@androID:ID/text1"        androID:layout_wIDth="50sp"        androID:layout_height="wrap_content"        androID:layout_alignParentBottom="true"        androID:layout_alignParenttop="true"        androID:layout_toRightOf="@ID/icon"        androID:ellipsize="marquee"        androID:gravity="center"        androID:paddingleft="6dip"        androID:singleline="true"        androID:textAppearance="?androID:attr/textAppearanceLarge"        androID:textStyle="bold" />    <TextVIEw        androID:ID="@+ID/start_point"        androID:layout_wIDth="wrap_content"        androID:layout_height="wrap_content"        androID:layout_alignParentRight="true"        androID:layout_alignParenttop="true"        androID:layout_toRightOf="@androID:ID/text1"        androID:ellipsize="marquee"        androID:paddingleft="6dip"        androID:paddingRight="6dip"        androID:singleline="true"        androID:textAppearance="?androID:attr/textAppearanceSmall" />    <TextVIEw        androID:ID="@+ID/end_point"        androID:layout_wIDth="wrap_content"        androID:layout_height="wrap_content"        androID:layout_alignParentBottom="true"        androID:layout_alignParentRight="true"        androID:layout_below="@ID/start_point"        androID:layout_toRightOf="@androID:ID/text1"        androID:ellipsize="marquee"        androID:gravity="center_vertical"        androID:paddingleft="6dip"        androID:paddingRight="6dip"        androID:singleline="true"        androID:textAppearance="?androID:attr/textAppearanceSmall" /></relativeLayout>

除了start_point和end_point的高度不相等外,它主要表现得像我想要的.我尝试过很多东西但是在语法错误或布局破坏方面都有所结束.有没有可行的解决方案来实现这一目标?

解决方法

It shows mostly like I want except that start_point and end_point are
not equal in height. I have trIEd many things but ended either in
Syntax error or in broken layout. Is there any working solution to
achIEve that?

在像这样的两个TextVIEw之前在布局中插入一个额外的视图,它将作为一个锚点,为TextVIEws提供相等的空间:

<relativeLayout>    // the icon and the first TextVIEw here    <VIEw androID:ID="@+ID/anchor" androID:layout_centerVertical="true" androID:layout_alignParentRight="true"              androID:layout_wIDth="2dp"        androID:layout_height="0dp"/>    // the two TextVIEw below it   <TextVIEw       androID:ID="@+ID/start_point" androID:layout_above="@ID/anchor" // the rest of the attributes />   <TextVIEw       androID:ID="@+ID/end_point" androID:layout_below="@ID/anchor" // the rest of the attributes /></relativeLayout>
总结

以上是内存溢出为你收集整理的android – 使相对布局中的两个文本视图占据高度的50%全部内容,希望文章能够帮你解决android – 使相对布局中的两个文本视图占据高度的50%所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1129154.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-30
下一篇 2022-05-30

发表评论

登录后才能评论

评论列表(0条)

保存