LinearLayout与4个图像 - 我不能看到他们洞
我有一个线性布局与4个图像水平方向。 ?我的问题是,第一图像裁剪,我不能看到他们两个在我的GALAXY S,只有在一些emulators..any帮助,请这是我的线性布局代码:LinearLayout与4个图像 - 我不能看到他们洞
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<ImageButton
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:background="@drawable/header_new_3"
android:layout_weight="1"
/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:background="@drawable/header_btn1"
/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:background="@drawable/header_btn2"
/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:background="@drawable/header_btn3"
/>
</LinearLayout>
这就是我想要的
,这就是我得到
@Jamo:此搜索:
image2,3,4:
你含布局fill_parent
,这意味着它仅限于其父的宽度(可能是整个屏幕)。每个ImageButton
设置为宽度wrap_content
,这意味着它只适合其内容的宽度。如果您使用的图像背景宽度总和超过总宽度,您将遇到问题。这似乎是发生了什么事。您无法将更多像素放入屏幕中。
更新:
与您提供的图形时,“你好”的形象是138px和明星为60像素。 138 + 60 * 3 = 318。如果你的屏幕宽度是480px(我认为Galaxy S是480宽),那么你应该能够适应。如果你把它们放到默认或mdpi文件夹(而Galaxy S是hdpi),那么这些将被缩放到1.5x,即477px。这应该仍然适合。
所以解决这个问题的唯一方法就是拥有更小的图形? –
我已经更新了一些快速计算。 LinearLayout是否真的是顶层布局?或者是否包含在其他内容中? – kabuko
我知道要创建类似的东西是使用RelativeLayout的这样的唯一方法:
<RelativeLayout android:layout_height="wrap_content"
android:layout_width="fill_parent">
<ImageView android:layout_alignParentRight="true"
android:id="@+id/iv4"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:src="@drawable/icon"/>
<ImageView android:layout_toLeftOf="@id/iv4"
android:id="@+id/iv3"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:src="@drawable/icon"/>
<ImageView android:layout_toLeftOf="@id/iv3"
android:id="@+id/iv2"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:src="@drawable/icon"/>
<ImageView android:layout_toLeftOf="@id/iv2"
android:id="@+id/iv1"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:src="@drawable/icon"/>
</RelativeLayout>
我们在先前的问题聊起这一点。请发布整个布局文件。如果总宽度受到外部LinearLayout父级的限制,那么layout_weight不会有太大的作用,正如其他帖子所暗示的那样。
此外,一些想法。
您对ImageView高度有“fill_parent”。我认为这些应该是“wrap_content”。你用“背景”而不是“src”来设置图像,这很奇怪。
此外,该第一个图像应该在另一个布局容器,以允许拉伸,不会搞砸'你好'。
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:layout_weight="1">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/header_new_3"
android:layout_gravity="center"
/>
</LinearLayout>
不是100%确定这正是你想要的,但最终目标是拉伸第一张图片而不以任何方式剪切。
你能给我们提供帮助测试的图片吗? –
当然,只需要一秒钟就可以上传它们 –