2017-03-17 2 views
-1

携帯とタブレット用のアプリを作成しています。そのモバイルでの完璧な作業。しかし、TabletのImageViewはモバイルと同じサイズで登場しています。画面サイズに関してImageViewをどのように設定できますか?モバイルとタブレットの両方に互換性のあるアプリUIを作成するにはどうすればいいですか?横長表示と縦長表示にも問題があります。あなたのイメージは次のように保存、ic_fishであれば...Android ImageViewモバイルとタブの両方に適しています

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

+0

私は質問ごとに一つの問題に固執することをお勧めします。 また、あなたのコードにその画像はどこですか?どのフォルダですか? DPIごとに異なる画像がありますか? – Olaia

+0

ImageViewの相対サイズは 'Linearlayout' +' android:layout_weight'、または 'match_parent'です –

答えて

1

を助けてください。

RES /描画可能-xhdpi - 大(9 "-10")あなたの必要

RES /描画可能-mhdpiあたりとして錠剤ic_fish(150 * 150) - 小さな(7 "-8")錠剤ic_fish( 100 * 100)あなたに必要な

のres /描画可能-hdpiごとなど - ごとなど他のすべてのデバイスのic_fish(* 50 50)あなたのあなたは、以下のように三つの異なるレイアウトを作成する必要が

を必要

のres/layout-sw720dp - 大きい(9 "-10")タブレット

のres /レイアウト-sw600dp - 小型(7 "-8")錠

のres /レイアウト - 他のすべてのデバイス

関連する問題