Android - ImageView - Multiple Screen Support - Set height/width as dp or match_parent/wrap_content? -


i trying adjust android app , feel similar on multiple screens/devices.

i know major part in provide multiple image sizes every image file according x1, x1.5, x2, x3, x4 ratios mdpi, hdpi, xhpi, xxhdpi , xxxhdpi respectively, , have finished doing today.

after doing this, have defined density independent pixel dimensions in @dimen.xml values resource correspond actual image sizes in pixels of mdpi resources. subsequently, have set imageviews in question's layout_width , layout_height dimension.

i @ loss, however, why application still looks different on mdpi emulator on hdpi emulator. highlight mean, i'll provide following screenshot showing hdpi , mpdi emulator next 1 (left hdpi (4" wvga nexus s) , right mdpi (5.4" fwvga)). want both of them mpdi version, i've done far apparently isn't working.

enter image description here enter image description here

i have 3 theories of own why not working way intend to:

1. not supposed set imageview layout_width , layout_height dp value, rather match_parent or wrap_content (?) (and change structure of .xml layouts in process).

2. not supposed define multiple drawable resources, multiple layout resources different screen sizes (?).

3. have misunderstood entire idea behind how supposed work (?).

i give example of 1 of list items can seen in first screenshot (@drawable/phone_speed_icon 64 x64 pixel resource in mpdi , 96x96 resource in hdpi, , @dimen/icon_attribute_size 64dp):

        <linearlayout             android:id="@+id/llspeed_presession"             android:layout_width="match_parent"             android:layout_height="wrap_content"             android:orientation="horizontal"             android:paddingbottom="10dp"             android:paddingend="20dp"             android:paddingstart="20dp"             android:weightsum="100">              <linearlayout                 android:layout_width="fill_parent"                 android:layout_height="@dimen/icon_attribute_size"                 android:layout_weight="20"                 android:weightsum="100">                  <linearlayout                     android:layout_width="match_parent"                     android:layout_height="match_parent"                     android:layout_weight="70"                     android:gravity="center"                     android:orientation="vertical">                       <imageview                         android:layout_width="@dimen/icon_attribute_size"                         android:layout_height="@dimen/icon_attribute_size"                         android:src="@drawable/phone_speed_icon" />                  </linearlayout>                  <textview                     android:layout_width="match_parent"                     android:layout_height="match_parent"                     android:layout_weight="30"                     android:gravity="center_vertical"                     android:paddingstart="10dp"                     android:text="speed"                     android:textappearance="@android:style/textappearance.large"                     android:textcolor="#878787"                     android:textstyle="bold" />              </linearlayout>               <linearlayout                 android:layout_width="match_parent"                 android:layout_height="match_parent"                 android:layout_weight="80"                 android:gravity="center">                  <android.support.v7.widget.switchcompat                     android:id="@+id/swspeed_presession"                     android:layout_width="wrap_content"                     android:layout_height="match_parent" />             </linearlayout>          </linearlayout> 

in end, have 4 questions i'd answered:

1. how make list items in screenshot 1 same on mdpi devices hdpi devices? have 1 of 3 theories mentioned earlier?

2. why header text ("what want measure?") wrapped on 1 device, not on other? use sp unit (via android:style/textapperance.textapperance.large)?

3. shouldn't more spaced out on hdpi device (if anything) rather less spaced out? hdpi emulator looks if "has got way less pixels available", if can understand i'm saying little.

4. how make fragments on second screenshot same? or should not want this, because hdpi (for reason) physically smaller, why layout less spread out?

anyway, have been @ day , more read more thouroughly confused get, appreciated!

you have option create multiple dimens.xml files depending on variety of factors. here you'll see current project looks various dimens.xml files in android studio based on screen width.

res values

however, can have different requirements each dimens file want. example, can create dimens files each density:

enter image description here

enter image description here


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -