
我有一个水平的linearVIEw,在左边有一些固定大小的东西,然后是一些文本应该尽可能地作为mich空间,但在右边应该是另一个固定大小的对象.
现在,我的问题是现在:当中间的文本太长时,右边的对象被推出窗口.当文本太短时,它不会位于窗口的右边界,而是直接位于文本旁边.
我该怎么做?到目前为止我的代码(正如你所看到的,我试图使用LayoutWeight,这没有帮助……):
<?xml version="1.0" enCoding="utf-8"?><linearLayout xmlns:androID="http://schemas.androID.com/apk/res/androID" androID:orIEntation="horizontal" androID:layout_wIDth="fill_parent" androID:layout_height="fill_parent"> <TextVIEw androID:ID="@+ID/important" androID:layout_wIDth="wrap_content" androID:layout_height="fill_parent" androID:layout_marginRight="10dp" androID:background="#000000" androID:layout_weight="1"/> <linearLayout androID:orIEntation="vertical" androID:layout_wIDth="wrap_content" androID:layout_height="fill_parent" androID:layout_weight="1"> <TextVIEw androID:ID="@+ID/name" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:paddingtop="5dp" androID:paddingRight="5dp" androID:paddingleft="0dp" androID:textcolor="#333333" androID:paddingBottom="0dp" androID:textSize="14sp" androID:scrollHorizontally="true"/> <TextVIEw androID:ID="@+ID/description" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:textcolor="#666666" androID:paddingtop="3dp" androID:paddingRight="5dp" androID:paddingleft="10dp" androID:paddingBottom="5dp" androID:textSize="12sp" /> </linearLayout> <ImageVIEw androID:ID="@+ID/lastpage" androID:src="@drawable/lastpage" androID:layout_wIDth="wrap_content" androID:layout_height="fill_parent" androID:layout_weight="200" androID:scaleType="center" androID:layout_gravity="right"/></linearLayout>解决方法 看看这个答案 Android: LinearView with fixed sized widgets left and right and a flexible one in the middle你可能只需要将你的中间元素的layout_wIDth设置为0px,使其不使用内容获得的宽度,而是通过权重来决定它.
希望这可以帮助.
总结以上是内存溢出为你收集整理的Android:LinearView左右固定大小的小部件,中间是灵活的小部件全部内容,希望文章能够帮你解决Android:LinearView左右固定大小的小部件,中间是灵活的小部件所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)