簡體   English   中英

Android ImageView克服linearlayout

[英]Android ImageView getting over linearlayout

我正在開發一個android應用程序,其布局如下圖所示:

屏幕截圖http://www.lebanon-trading-center.com/daymanager/layout.PNG

該布局包含2個主要的線性布局:水平布局占用設備高度的90%,垂直布局占用設備高度的10%。 在水平linearlayout內有三個linearlayout(兩個紅色,一個包含imageview)。 每個紅色布局是屏幕寬度的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將越過底部的linearlayout(黑色的),兩個紅色的布局將受到擠壓。

屏幕截圖http://www.lebanon-trading-center.com/daymanager/layout2.PNG

我的問題是我該如何解決該問題並在所有平板電腦上使用相同的布局功能?

Try this way,hope this will help you to solve your problem.

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:orientation="horizontal"
        android:layout_weight="0.90">

        <LinearLayout
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:orientation="vertical"
            android:layout_weight="0.10"
            android:background="#ff0000" >
        </LinearLayout>

        <LinearLayout
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:gravity="center_horizontal"
            android:layout_weight="0.80" >

            <ImageView
                android:id="@+id/imageView1"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:scaleType="fitXY"
                android:src="@drawable/ic_launcher" />

        </LinearLayout>

        <LinearLayout
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:orientation="vertical"
            android:layout_weight="0.10"
            android:background="#ff0000"  >
        </LinearLayout>

    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:orientation="vertical"
        android:layout_weight="0.10"
        android:background="#000000" >
    </LinearLayout>

</LinearLayout>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM