2013-06-14 5 views
0

Я не могу понять, почему мой макет не расширяется, чтобы соответствовать другим экранам, я развиваюсь на nexus 7, макет должен исправить, чтобы соответствовать всей странице, но это не так. вот мой код макета ...Поддерживает размер экрана с несколькими размерами android

<?xml version="1.0" encoding="utf-8"?> 
<!-- 

--> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    > 
    <LinearLayout style="@style/TitleBar"> 
     <ImageButton style="@style/TitleBarAction" 
      android:contentDescription="@string/description_home" 
      android:src="@drawable/title_home" 
      android:onClick="onClickHome" /> 

     <ImageView style="@style/TitleBarSeparator" 
      android:contentDescription="@string/description_title" /> 
     <TextView style="@style/TitleBarText" /> 
     <ImageButton style="@style/TitleBarAction" 
      android:contentDescription="@string/description_about" 
      android:src="@drawable/title_about" 
      android:onClick="onClickAbout" /> 
     <ImageButton style="@style/TitleBarAction" 
      android:contentDescription="@string/description_connect" 
      android:src="@drawable/title_connect" 
      android:onClick="onClickConnect" /> 
      <ImageButton style="@style/TitleBarAction" 
      android:contentDescription="@string/description_connect" 
      android:src="@drawable/title_facebook" 
      android:onClick="onClickFacebook" /> 
      <ImageButton style="@style/TitleBarAction" 
      android:contentDescription="@string/description_connect" 
      android:src="@drawable/title_twitter" 
      android:onClick="onClickTwitter" /> 
    </LinearLayout> 

    <RelativeLayout 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent"> 


     <!-- Main Title --> 


     <TextView 
      android:id="@+id/header1" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:text="@string/heading_1" 
      android:textSize="20sp"/> 

     <TextView 
      android:id="@+id/distance_text" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="@string/distance" 

      android:layout_below="@+id/header1" 
      android:textSize="60sp" /> 


     <TextView 
      android:id="@+id/header2" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_below="@+id/distance_text" 
      android:layout_marginLeft="210sp" 
      android:text="@string/heading_2" 
      android:textSize="20sp" /> 


     <!-- First column --> 


     <TextView 
      android:id="@+id/consumption_header" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginRight="0dp" 
      android:layout_marginTop="330dp" 
      android:text="@string/heading_consumption" 
      android:textAppearance="?android:attr/textAppearanceMedium" /> 

     <TextView 
      android:id="@+id/consumption_text" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_below="@+id/consumption_header" 
      android:text="@string/text_consumption" /> 

     <TextView 
      android:id="@+id/avg_consumption_header" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="@string/heading_avg_consumption" 
      android:layout_below="@+id/consumption_text" 
      android:textAppearance="?android:attr/textAppearanceMedium" /> 

     <TextView 
      android:id="@+id/avg_consumption_text" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_below="@+id/avg_consumption_header" 
      android:text="@string/text_avg_consumption" /> 

     <TextView 
      android:id="@+id/total_consumption_header" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="@string/heading_total_consumption" 
      android:layout_below="@+id/avg_consumption_text" 
      android:textAppearance="?android:attr/textAppearanceMedium" /> 

     <TextView 
      android:id="@+id/total_consumption_text" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_below="@+id/total_consumption_header" 
      android:text="@string/text_total_consumption" /> 



     <!-- Second column --> 

     <TextView 
      android:id="@+id/speed_header" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="@string/heading_speed" 
      android:layout_marginLeft="100dp" 
      android:layout_marginTop="150dp" 
      android:textAppearance="?android:attr/textAppearanceMedium" /> 

     <TextView 
      android:id="@+id/speed_text" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="@string/text_speed" 
      android:layout_marginLeft="100dp" 
      android:layout_marginTop="170dp" /> 


     <TextView 
      android:id="@+id/avg_speed_header" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="@string/heading_avg_speed" 
      android:layout_marginLeft="100dp" 
      android:layout_below="@+id/speed_text" 
      android:textAppearance="?android:attr/textAppearanceMedium" /> 

     <TextView 
      android:id="@+id/avg_speed_text" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="@string/text_avg_speed" 
      android:layout_marginLeft="100dp" 
      android:layout_below="@+id/avg_speed_header" /> 

     <TextView 
      android:id="@+id/max_speed_header" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="@string/heading_maximum_speed" 
      android:layout_marginLeft="100dp" 
      android:layout_below="@+id/avg_speed_text" 
      android:textAppearance="?android:attr/textAppearanceMedium" /> 

     <TextView 
      android:id="@+id/max_speed_text" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginLeft="100dp" 
      android:layout_below="@+id/max_speed_header" 
      android:text="@string/text_maximum_speed" /> 
    </RelativeLayout> 

</LinearLayout> 

файл манифеста

android:versionCode="1" 
    android:versionName="1.0" > 

    <uses-sdk android:minSdkVersion="12" 
       android:targetSdkVersion="17" /> 
    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" /> 
    <uses-permission android:name="android.permission.BLUETOOTH" /> 

    <permission 
     android:name="com.example.burtoncruiser.permission.MAPS_RECEIVE" 
     android:protectionLevel="signature"/> 
    <uses-permission android:name="com.example.burtoncruiser.permission.MAPS_RECEIVE"/> 
    <uses-permission android:name="android.permission.INTERNET"/> 
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> 
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> 
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/> 
    <!-- The following two permissions are not required to use 
     Google Maps Android API v2, but are recommended. --> 
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/> 
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> 

    <uses-feature 
     android:glEsVersion="0x00020000" 
     android:required="true"/> 

<supports-screens 
      android:smallScreens="true" 
       android:normalScreens="true" 
       android:largeScreens= "true" 
       android:anyDensity="true" 
       android:compatibleWidthLimitDp="120"/> 

    <application 
     android:allowBackup="true" 
     android:theme="@style/Theme.D1" 
     android:icon="@drawable/icon" 
     android:label="@string/app_name"> 

     <activity android:name=".MainActivity" 
        android:label="@string/app_name"> 
     <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 
      <category android:name="android.intent.category.LAUNCHER" /> 
     </intent-filter> 
     </activity> 

     <activity android:name=".CarStatistics" 
      android:theme="@style/Theme.D1" 
      android:label="@string/title_feature1" 
      /> 
     <activity android:name=".Battery" 
      android:theme="@style/Theme.D1" 
      android:label="@string/title_feature2" 
      /> 
     <activity android:name=".Map" 
      android:theme="@style/Theme.D1" 
      android:label="@string/title_feature3" 
      /> 
     <activity android:name=".CarControl" 
      android:theme="@style/Theme.D1" 
      android:label="@string/title_feature4" 
      /> 
     <activity android:name=".Profile" 
      android:theme="@style/Theme.D1" 
      android:label="@string/title_feature5" 
      /> 
     <activity android:name=".BluetoothDebugging" 
      android:theme="@style/Theme.D1" 
      android:label="@string/title_feature6" 
      /> 
     <activity android:name=".AboutActivity" 
      android:theme="@style/Theme.D1" 
      android:label="@string/title_about" 
      /> 
     <activity android:name=".SearchActivity" 
      android:theme="@style/Theme.D1" 
      android:label="@string/title_search" 
      /> 
     <activity android:name=".DeviceListActivity" 
      android:label="@string/select_device" 
      android:theme="@android:style/Theme.Dialog" 
      android:configChanges="orientation|keyboardHidden" /> 
     <meta-data 
      android:name="com.google.android.maps.v2.API_KEY" 
      android:value="AIzaSyAJstC_UQnirAU1enW1g-_xRZdHWm8prnA"/> 


     </application> 


</manifest> 

меня искать решения на StackOverflow, но ни одно из предложений не работали.

здесь является печать, как это выглядит на enter image description here SDK и это, как он выглядит на телефоне enter image description here Любая помощь будет большим

Спасибо

+2

'андроида: layout_height = "wrap_content"'. Переключитесь на 'fill_parent' или' match_parent'. –

+0

Я пробовал это уже и, похоже, не работает – user1175889

ответ

3

вы просто не имеют достаточное количество контента, чтобы соответствовать экрану. Вы можете настроить масштаб гравитации на центр, чтобы центрировать все.

Вы можете создавать собственные макеты для телефонов и планшетов (7" + 10") и попытаться изменить порядок элементов, чтобы использовать недвижимое имущество лучше

КСТАТИ: В SDK предварительный просмотр установлен на Nexus One, который имеет много намного меньший размер экрана. Вот почему в sdk это выглядит так по-разному.

Прочитайте это: Supporting Multiple Screens

+0

Я новичок в android, как бы вы сосредоточили все, и как вы можете изменить размер предварительного просмотра экрана sdk – user1175889

+0

упустите второй вопрос, спасибо – user1175889

+0

Но как бы вы сосредоточили все – user1175889