簡體   English   中英

Android垂直屏幕百分比划分

[英]Android Vertical screen percent divide

我寫這個xml文件:

向上的代碼工作得很好,但是我想要這個android:src="@drawable/down"圖像適合垂直屏幕的80%,我該怎么做?

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

    <LinearLayout 
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:weightSum="100">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="60" >

    <ImageView
        android:id="@+id/downImage"
        android:layout_width="match_parent"
        android:layout_height="match_parent"

        android:src="@drawable/down" />
    </LinearLayout>


    </LinearLayout>

如果我正確理解您的信息,並且您想要兩張一張一張,另一張一張占據80%的屏幕,那么這是解決方案:

<?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">

    <ImageView
        android:id="@+id/backImage"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="0.2"
        android:scaleType="fitXY"
        android:src="@drawable/back"
     />

    <ImageView
        android:id="@+id/downImage"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="0.8"
        android:src="@drawable/down" />

</LinearLayout>

暫無
暫無

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

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