Reputation: 697
Im creating an app and im testing on a android tablet. Which means im using dimensions and positioning to fit the tablet screen. However as this app will be available for both tablet and phone im wondering is there a way of auto scaling for any device??
Thanks
Im using map fragment, rss feeds contained in listview and i have buttons.
im wondering if its complicated to scale down for a android phone?? or is it simple enough. Im currently testing on a tablet running 4.0.4 but app is compatible with newer and older android versions.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/tableLayout1"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@color/white">
<fragment
android:id="@+id/map"
android:layout_width="300dp"
android:layout_height="413dp"
android:layout_marginTop="5dp"
android:layout_toRightOf="@+id/button5"
class="com.google.android.gms.maps.MapFragment" />
<Button
android:id="@+id/button3"
android:layout_width="305dp"
android:layout_height="100dp"
android:layout_marginLeft="34dp"
android:layout_marginTop="10dp"
android:onClick="ClickTourismButton"
android:layout_below="@+id/map"
android:text="Touism Guide" />
<TextView
android:id="@+id/button5"
android:layout_width="34dp"
android:textIsSelectable="true"
android:layout_height="match_parent"
android:background="@color/grey"
/>
<TextView
android:id="@+id/button6"
android:layout_width="34dp"
android:textIsSelectable="true"
android:layout_alignParentRight="true"
android:layout_height="match_parent"
android:background="@color/grey"
/>
<Button
android:id="@+id/button4"
android:layout_width="305dp"
android:layout_height="100dp"
android:layout_marginLeft="34dp"
android:layout_below="@+id/button3"
android:text="Whats Nearby" />
<Button
android:id="@+id/button2"
android:layout_width="305dp"
android:layout_height="100dp"
android:layout_marginLeft="34dp"
android:layout_below="@+id/button4"
android:text="Favouites" />
<Button
android:id="@+id/button1"
style="?android:attr/buttonStyleSmall"
android:layout_width="304dp"
android:layout_marginLeft="34dp"
android:layout_height="100dp"
android:layout_below="@+id/button2"
android:text="See Full Map" />
<TextView
android:layout_width="260dp"
android:layout_height="413dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:textIsSelectable="true"
android:layout_toRightOf="@+id/map"
android:layout_toLeftOf="@+id/button6"
android:id="@+id/feedupdate1" />
<ListView
android:id="@android:id/list"
android:background="@color/red"
android:layout_toRightOf="@+id/map"
android:layout_width="260dp"
android:layout_marginTop="5dp"
android:layout_marginLeft="10dp"
android:layout_height="413dp" />
<TextView
android:id="@+id/empty"
android:textIsSelectable="true"
android:layout_width="260dp"
android:layout_height="413dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
/>
<TextView
android:id="@+id/feedupdate"
android:layout_width="260dp"
android:layout_height="390dp"
android:layout_marginLeft="6dp"
android:layout_marginTop="430dp"
android:textIsSelectable="true"
android:layout_toRightOf="@+id/button3"
/>
<ListView
android:id="@+id/list1"
android:background="@color/blue"
android:layout_toRightOf="@+id/button3"
android:layout_width="260dp"
android:layout_marginTop="430dp"
android:layout_marginLeft="6dp"
android:layout_height="390dp" />
</RelativeLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/LinearLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:background="@color/white">
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<fragment
android:id="@+id/map"
android:layout_marginTop="5dp"
android:layout_weight="1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
class="com.google.android.gms.maps.MapFragment"
/>
<Button
android:id="@+id/button3"
android:layout_weight=".10"
android:layout_marginLeft="34dp"
android:layout_marginTop="10dp"
android:layout_width="0dp"
android:layout_height="0dp"
android:onClick="ClickTourismButton"
android:label="@string/Tourism" />
<Button
android:id="@+id/button4"
android:layout_weight=".10"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginLeft="34dp"
android:label="@string/Nearby" />
<Button
android:id="@+id/button2"
android:layout_weight=".25"
android:layout_marginLeft="34dp"
android:layout_width="300dp"
android:layout_height="50dp"
android:label="@string/Favourites" />
<Button
android:id="@+id/button1"
android:layout_weight=".25"
android:layout_width="300dp"
android:layout_height="50dp"
android:layout_marginLeft="34dp"
android:label="@string/Map" />
</LinearLayout>
<LinearLayout
android:id="@+id/linearLayout2"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:textIsSelectable="true"
android:id="@+id/feedupdate1" />
<ListView
android:id="@android:id/list"
android:background="@color/red"
android:layout_weight="1"
android:layout_marginTop="5dp"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginLeft="10dp"/>
<TextView
android:id="@+id/empty"
android:textIsSelectable="true"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"/>
<TextView
android:id="@+id/feedupdate"
android:layout_marginLeft="6dp"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginTop="430dp"
android:textIsSelectable="true"/>
<ListView
android:id="@+id/list1"
android:background="@color/blue"
android:layout_weight="1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginTop="430dp"
android:layout_marginLeft="6dp" />
</LinearLayout>
</LinearLayout>
Upvotes: 0
Views: 1431
Reputation: 1632
I don't think you will have a problem as long as you are making use of fill_parent
, wrap_content
wherever possible. still do search "Android Compatibility Package" on developers.android.com
You will get a handful of info on that link.
Upvotes: 1
Reputation:
It is better to use layout weight
and weightsum
property of the view wherever possible. It'll ensure that your views take up only that percentage of the screen space that you wish to specify. Thus, it'll scale your views for viewing in small or big screens.
Upvotes: 1