【发布时间】:2014-06-20 14:10:09
【问题描述】:
我正在开发一个android应用程序,布局如下图所示:
Screenshot http://www.lebanon-trading-center.com/daymanager/layout.PNG
布局包含两个主要的线性布局:一个占设备高度 90% 的水平布局和一个占设备高度 10% 的垂直布局。在水平线性布局内有三个线性布局(两个红色和一个包含图像视图)。每个红色布局是屏幕宽度的 10%,而包含 ImageView 的布局是 80%。这是xml代码:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="1" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_weight="0.9"
android:weightSum="1"
>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_weight="0.1"
android:background="#ff0000" >
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="horizontal"
android:gravity="center_horizontal"
android:layout_weight="0.8" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:src="@drawable/ic_launcher" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_weight="0.1"
android:background="#ff0000" >
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_weight="0.1"
android:background="#000000" >
</LinearLayout>
</LinearLayout>
问题是,当我将 PNG 图像(1036px X 730px)设置为 ImageView 的源时,ImageView 将越过底部的线性布局(黑色的),两个红色布局将被挤压。
Screenshot http://www.lebanon-trading-center.com/daymanager/layout2.PNG
我的问题是如何解决问题并在各种平板电脑上使用相同的布局?
【问题讨论】:
-
你可以发布一个布局的图像,当你设置 png 图像(1036px X 730px)
标签: java android android-layout