2013-03-25 182 views
0

我在Android平板電腦上創建應用和即時測試。這意味着即時通訊使用尺寸和位置來適應平板電腦屏幕。然而,因爲這個應用程序將可用於平板電腦和手機我想知道是否有任何設備自動縮放的方式?使用地圖片段將Android平板電腦應用調整爲Android手機

由於

enter image description here

林,RSS饋送包含在列表視圖和我的按鈕。

即時通訊想知道如果它的複雜縮小爲Android手機?還是很簡單。我目前在運行4.0.4的平板電腦上進行測試,但應用程序與較新和較舊的Android版本兼容。

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

你的形象沒有在這裏看到 – Pratik 2013-03-25 10:26:00

+0

這個主題是廣泛描述[這裏](http://developer.android.com/design/style/devices-displays.html)。 – adrianp 2013-03-25 10:27:12

+0

增加我的'reptutation'。應用程序的主屏幕是你看到的。我好奇佈局縮放? ive聽說你需要的是兼容性庫或其他東西? – PropK 2013-03-25 10:27:54

回答

1

最好是儘可能使用視圖layout weightweightsum財產。它會確保您的視圖只佔用您希望指定的屏幕空間的百分比。因此,它將擴大您的觀點,以便在小屏幕或大屏幕上觀看。

+0

我在上面添加了我的layout.xml文件。我應該擺脫寬度和高度,只使用佈局重量和權重? – PropK 2013-03-25 10:45:42

+0

除非你想使用fill_parent和wrap_content(在不同的屏幕尺寸上看起來很糟糕),我建議你爲每個視圖定義權重。對這些使用明確的值會將視圖限制到特定的寬度或高度,但使用權重會根據屏幕大小展開或摺疊視圖。 – 2013-03-25 10:52:58

+0

好的,我將如何去使用權重來重新創建我的佈局中的黑色矩形片段的確切位置?我認爲它仍然可以使用android:layout_marginTop =「5dp」 android:layout_toRightOf =「@ + id/button5」 – PropK 2013-03-25 11:00:25

1

只要您在儘可能使用fill_parentwrap_content,我認爲您不會遇到任何問題。仍然在developers.android.com上搜索「Android Compatibility Package」

您將在該鏈接上獲得一些信息。

+0

以上每個組件使用單獨的寬度和高度 – PropK 2013-03-25 10:46:34

+0

對於不同的設備,這可能會成爲一個問題。因爲它可以在所有設備上工作,您必須使用「wrap_content」或「fill_parent」,這在我看來是更一般的。 – 2013-03-25 12:57:36

相關問題