0

I have some thought on how layout works in Android development.

I have written an app for a tablet with full HD resolution (10" Xperia Z1 Tablet, 1920 x 1200). The app looks good and works well on the tablet. The app is always in landscape mode.

When I install the same app on a 4.8" phone, that has half the resolution (1280 x 800), I need to specify a different layout and name the folders using the w<dp> thing (and change the layout so it fits the phone better).

Tablet

So, for the tablet I think I should use:

layout-w1359dp-land

and the reason is this:

Dpi: 226 (http://pixeldensitycalculator.com/?h=1920&v=1200&d=10)
Width (px): 1920
Calculation: 1920 / (226/160) = 1920 / 1,4125 = 1359

Phone

And for the phone

layout-w652dp-land

and the reason is this:

Dpi: 314 (http://pixeldensitycalculator.com/?h=1280&v=800&d=4.8)
Width (px): 1280
Calculation: 1280 / (314/160) = 1280 / 1,9625= 652

The problem

It's not working. It looks as bad as it always does. It doesn't seem that it takes the layout-w652dp-land into account at all.

The images shows the problem, and I don't get why it doesn't matter what I do in the layout-w652dp-land folder.

What might be the reason why the folders are not "respected"?

TABLET VIEW (ALL OK):

enter image description here

** SAMSUNG S3 PHONE VIEW (before and after the folder-name-change) **

enter image description here

Edit

I waited with posting the XML, as I didn't want to make this post too large, and I wasn't sure it was relevant to the "overall" question, but here it is:

booking_row.xml - each row is defined by this:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="50dp"
    android:background="#AAF0F0F0">

    <!-- TODO: Update blank fragment layout -->

    <TableLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_gravity="center" >

        <TableRow
            android:id="@+id/booking_row_tablerow"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:padding="0dp"
            android:gravity="center_vertical"
            android:background="@android:drawable/list_selector_background"
            >

            <View
                android:id="@+id/booking_row_status_color"
                android:layout_width="30dp"
                android:background="@android:color/holo_red_dark"></View>

            <View
                android:id="@+id/View01"
                android:layout_width="3px"
                android:layout_height="fill_parent"
                android:background="#22000000" />

            <FrameLayout
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:background="#FFFFFF"
                android:layout_gravity="center" >

                <TextView
                    android:id="@+id/booking_row_tv_time"
                    android:layout_width="60dp"
                    android:layout_height="fill_parent"
                    android:text="13:10"
                    android:textSize="10sp"
                    android:layout_column="3"
                    android:padding="5dp"

                    android:gravity="center"
                    />
            </FrameLayout>

            <View
                android:id="@+id/View01"
                android:layout_width="0px"
                android:layout_height="0dp"
                android:background="#46000000" />
            <View
                android:id="@+id/View01"
                android:layout_width="0px"
                android:layout_height="0dp"
                android:background="#00ffffff" />

            <TextView
                android:id="@+id/booking_row_tv_name"
                android:layout_width="200dp"
                android:text="Test test"
                android:textSize="17sp"
                android:layout_column="3"
                android:padding="5dp" />

            <View
                android:id="@+id/View01"
                android:layout_width="3px"
                android:layout_height="fill_parent"
                android:background="#22000000" />

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/booking_row_imageview_direction"
                android:layout_column="1"
                android:src="@drawable/icon_car_incoming"
                android:padding="5dp"
                />

            <View
                android:id="@+id/View01"
                android:layout_width="3px"
                android:layout_height="fill_parent"
                android:background="#22000000" />

            <TextView
                android:id="@+id/booking_row_tv_address"
                android:layout_width="250dp"
                android:text="Some address"
                android:textSize="17sp"
                android:layout_column="3"
                android:padding="5dp" />

            <View
                android:id="@+id/View01"
                android:layout_width="3px"
                android:layout_height="fill_parent"
                android:background="#22000000" />

            <TextView
                android:id="@+id/booking_row_tv_delayInfo"
                android:layout_width="80dp"
                android:text="Info info"
                android:textSize="17sp"
                android:layout_column="3"
                android:padding="5dp" />

            <View
                android:id="@+id/View01"
                android:layout_width="3px"
                android:layout_height="fill_parent"
                android:background="#22000000" />


            <ImageView
                android:layout_margin="5dp"
                android:layout_width="wrap_content"
                android:id="@+id/booking_row_gps_valid"
                android:src="@drawable/icon_gps_valid" />

            <View
                android:id="@+id/View01"
                android:layout_width="3px"
                android:layout_height="fill_parent"
                android:background="#22000000"
                android:visibility="gone" />

            <TextView
                android:id="@+id/booking_row_tv_miscInfo"
                android:layout_width="200dp"
                android:text="Framplats, ENS"
                android:textSize="30sp"
                android:layout_column="3"
                android:padding="5dp"
                android:visibility="gone" />
        </TableRow>

    </TableLayout>
</FrameLayout>
halfer
  • 19,824
  • 17
  • 99
  • 186
Ted
  • 19,727
  • 35
  • 96
  • 154
  • Which Android version are you supporting since these features are only available since API 13. I also wonder why you use such specific widths, why not just 600dp? Like the values the Android developers site proposes: http://developer.android.com/guide/topics/resources/providing-resources.html#BestMatch – RobinDeCroon Jan 26 '14 at 14:50
  • This is API version 18, so thats not an issue. Well, they are more specific to what we are using (this is not a Play-store app). But it doesnt matter if I choose 600dp, still no change at all. – Ted Jan 26 '14 at 17:03
  • What does your xml files look like? Could you post them? Are you using the layout_weight attributes or just plain 'dp' values? Just trying to figure out what could be wrong. – RobinDeCroon Jan 26 '14 at 19:54
  • Well, I wasnt sure the XML would help. I am not using weights, because I dont want the row to have weights as it would each column have different widhts on each row (the rows are independent from each other since its just a list). The general point I am trying to make first why the folder-options does not work, and... stuff. – Ted Jan 27 '14 at 23:38

0 Answers0