简体   繁体   English

android线性布局解决方案

[英]android linear layout solution

what i'm trying to achieve is #1 but what i get is #2 我想要实现的是#1但我得到的是#2

http://s48.radikal.ru/i120/1005/ff/6e439e04bbc8.jpg http://s48.radikal.ru/i120/1005/ff/6e439e04bbc8.jpg

it seems linear layout stacks with height of it's first element and shrinks second's element height to that. 似乎线性布局堆栈的高度是其第一个元素的高度,而第二个元素的高度则缩小到该高度。

the xml for those is the following: 这些的xml如下:


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
   xmlns:android="http://schemas.android.com/apk/res/android"
   android:layout_width="fill_parent"
   android:layout_height="wrap_content"
   android:orientation="horizontal"
   android:background="#FFFFEE"
>
 <ImageView 
  android:id="@+id/thumb"
  android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:src="@drawable/example" 
    android:layout_weight="5"
 />
 <TextView
  android:id="@+id/text" 
  android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_weight="2" 
    android:text="Aaa aaaaa aaa aaaaa, aaaaaaa aaa aaa a, aaa aa aaaaaaa aaa aa. Aaa aaaaa aaa aaaaa, aaaaaaa aaa aaa a, aaa aa aaaaaaa aaa aa. Aaa aaaaa aaa aaaaa, aaaaaaa aaa aaa a, aaa aa aaaaaaa aaa aa. Aaa aaaaa aaa aaaaa, aaaaaaa aaa aaa a, aaa aa aaaaaaa aaa aa. Aaa aaaaa aaa aaaaa, aaaaaaa aaa aaa a, aaa aa aaaaaaa aaa aa. Aaa aaaaa aaa aaaaa, aaaaaaa aaa aaa a, aaa aa aaaaaaa aaa aa."
 />
</LinearLayout>

Your XML is incomplete and would help your question, but the obvious thing to try seems to be to include 您的XML不完整,可以帮助您解决问题,但显而易见的尝试似乎是要包括

layout_height="fill_parent"

in the attributes of the second element 在第二个元素的属性中

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM