-1
我正在爲手機和平板電腦創建應用程序。其在移動中的完美工作。但是,Tablet中的ImageView與移動設備顯示的尺寸相同。如何設置ImageView相對於屏幕尺寸?如何創建兼容Mobile和Tablet的應用程序UI?橫向視圖和縱向視圖也有問題。請幫助...Android ImageView適用於手機和Tab
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="fill_parent" >
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/imageView"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:src="@mipmap/ic_fish"
android:minHeight="300sp" />
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/linearLayout"
android:weightSum="1"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="false"
android:background="@color/bright_foreground_material_dark"
android:layout_above="@+id/linearLayout2"
android:layout_below="@+id/imageView">
<TextView
android:id="@+id/name"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/ranklabel"
android:textSize="25dp"
android:textStyle="normal|bold"
android:textIsSelectable="false"
android:drawableLeft="@android:drawable/ic_menu_info_details"
android:gravity="center|left"
android:typeface="sans"
android:drawableTint="@color/background_material_dark"
android:textColor="@color/colorPrimary"
android:layout_weight=".33"
android:background="@color/material_grey_100" />
<View style="@style/Divider"
android:background="#bab8b8" />
<TextView
android:id="@+id/number"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/name"
android:textSize="20dp"
android:layout_weight=".33"
android:drawableLeft="@android:drawable/ic_menu_info_details"
android:gravity="center|left"
android:typeface="sans"
android:drawableTint="@android:color/background_dark"
android:layout_marginLeft="0dp"
android:textColor="@color/colorPrimary"
android:textStyle="normal"
android:background="@color/material_grey_100" />
<View style="@style/Divider"
android:background="#bab8b8" />
<TextView
android:id="@+id/address"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/number"
android:textStyle="normal"
android:textSize="20dp"
android:drawableLeft="@android:drawable/ic_menu_info_details"
android:gravity="center|left"
android:layout_weight=".33"
android:typeface="sans"
android:drawableTint="@android:color/background_dark"
android:textColor="@color/colorPrimary"
android:background="@color/material_grey_100" />
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="1"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:id="@+id/linearLayout2">
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/callButton"
android:layout_gravity="center_horizontal"
android:text="Read More"
android:textColor="@color/colorPrimary"
android:textStyle="normal|bold"
android:typeface="sans"
android:textSize="25dp"
android:background="@color/material_deep_teal_500"
android:minHeight="100dp" />
</LinearLayout>
我建議堅持每題一個問題。 另外,代碼中的圖像在哪裏?什麼文件夾?每個不同的DPI有不同的圖像嗎? – Olaia
使ImageView具有相對大小 - 使用'Linearlayout' +'android:layout_weight'或'match_parent' –