2013-03-25 185 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

相关问题