Android TableRow儿童问题

Android TableRow儿童问题,第1张

概述我有一个目前有3行的TableLayout,每行有一个子项,一个TextView.我的问题是TextViews宽度不应该像他们应该的那样“match_parent”.我已经按照不为它们定义高度和宽度的程序( like the documentation says)但由于某种原因问题仍然存在. 我打开了hierarchyviewer并查看了值,TableRow填充宽度,但TextView没有填充行, 我有一个目前有3行的tableLayout,每行有一个子项,一个TextVIEw.我的问题是TextVIEws宽度不应该像他们应该的那样“match_parent”.我已经按照不为它们定义高度和宽度的程序( like the documentation says)但由于某种原因问题仍然存在.

我打开了hIErarchyvIEwer并查看了值,tableRow填充宽度,但TextVIEw没有填充行,它只是包装内容.完整的xml布局如下,有没有人有任何想法?

<?xml version="1.0" enCoding="utf-8"?><tableLayout xmlns:androID="http://schemas.androID.com/apk/res/androID"androID:orIEntation="vertical"androID:layout_wIDth="fill_parent"androID:layout_height="fill_parent"><tableRow    androID:layout_wIDth="match_parent"    androID:layout_height="wrap_content">       <TextVIEw        androID:background="@drawable/textlines"        androID:text="@string/text1_string"        androID:textcolor="#000000"        androID:padding="5dp">    </TextVIEw></tableRow><tableRow    androID:layout_wIDth="match_parent"    androID:layout_height="wrap_content">       <TextVIEw        androID:background="@drawable/textlines"        androID:text="@string/text1_string"        androID:textcolor="#000000"        androID:padding="5dp">    </TextVIEw></tableRow><tableRow    androID:layout_wIDth="match_parent"    androID:layout_height="wrap_content">       <TextVIEw        androID:background="@drawable/textlines"        androID:text="@string/text1_string"        androID:textcolor="#000000"        androID:padding="5dp">    </TextVIEw></tableRow></tableLayout>

另外,我将包含@ drawable / textlines的xml文件.也许问题在那里? (文本行代码来自这里提供的关于边界问题的解决方案)我非常理解它,我认为它不应该影响我的问题,但我可能是错的.无论如何,这里是:

<?xml version="1.0" enCoding="utf-8"?><@R_620_3419@ xmlns:androID="http://schemas.androID.com/apk/res/androID" ><item>  <shape     androID:shape="rectangle">        <stroke androID:wIDth="1dp" androID:color="#FF000000" />        <solID androID:color="#FFddddDD" />    </shape></item><item androID:top="1dp" androID:bottom="1dp">   <shape     androID:shape="rectangle">        <stroke androID:wIDth="1dp" androID:color="#FFddddDD" />        <solID androID:color="#00000000" />    </shape></item></@R_620_3419@>
解决方法 我不知道为什么会这样,但你可以通过添加:

androID:layout_weight="1"

给你的孩子TextVIEws,或添加:

androID:stretchColumns="0"

到您的父tableLayout.

总结

以上是内存溢出为你收集整理的Android TableRow儿童问题全部内容,希望文章能够帮你解决Android TableRow儿童问题所遇到的程序开发问题。

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

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

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

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

发表评论

登录后才能评论

评论列表(0条)

保存