2014-05-22 52 views
0

我的硬件不同:布局看设备上

  • 谷歌眼镜(屏幕像素密度= 1.5,640 * 360像素分辨率)

  • VUZIX M100(屏幕像素密度= 0.75,432 * 244px分辨率)

这里是我的布局看起来像在谷歌玻璃:

enter image description here

和VUZIX:

enter image description here

布局源:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/ll_root" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_margin="@dimen/activity_margin" 
    android:baselineAligned="false" 
    android:orientation="horizontal" > 

    <FrameLayout 
     android:id="@+id/content_secondary" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_weight="2" 
     android:paddingRight="@dimen/layout_padding"> 
    </FrameLayout> 

    <View 
     android:layout_width="@dimen/separator_width" 
     android:layout_height="match_parent" 
     android:layout_marginBottom="@dimen/separator_margin_bottom" 
     android:layout_marginTop="@dimen/separator_margin_top" 
     android:background="@android:color/darker_gray" /> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_weight="1" 
     android:orientation="vertical" > 

     <TextView 
      android:id="@+id/tv_instructions" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:gravity="center_horizontal" 
      android:text="@string/instruction_sign_in" 
      android:textSize="@dimen/instructions_text_size" /> 

     <FrameLayout 
      android:id="@+id/content_primary" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:paddingLeft="@dimen/container_primary_padding_left" > 
     </FrameLayout> 
    </LinearLayout> 

<dimen name="activity_margin">1dp</dimen> 
<dimen name="separator_width">1dp</dimen> 
<dimen name="separator_margin_top">30dp</dimen> 
<dimen name="separator_margin_bottom">30dp</dimen> 
<dimen name="instructions_text_size">20sp</dimen> 
<dimen name="layout_padding">3dp</dimen> 
<dimen name="medium_text_size">30sp</dimen> 
<dimen name="small_text_size">22sp</dimen> 
<dimen name="almost_large_text_size">50sp</dimen> 
<dimen name="large_text_size">60sp</dimen> 
<dimen name="huge_text_size">100sp</dimen> 
<dimen name="container_primary_padding_left">10dp</dimen> 

来源为右布局部分:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:padding="10dp"> 

    <TextView 
     android:layout_below="@id/tv_row_label" 
     android:id="@+id/tv_destination" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:gravity="center_horizontal" 
     android:text="AA" 
     android:textSize="@dimen/huge_text_size" /> 

</RelativeLayout> 

正如你所看到的所有值都是密度无关。但布局仍然看起来不同。可能是什么问题呢?

+1

您的设备是否有不同的物理尺寸? –

+0

@FD_他们有一个投影仪屏幕,所以我不能说真的。 –

+0

嘿@IgorFilippov:你是如何为Google Glass和Vuzix m100开发的?你有使用不同的SDK? – Shruti

回答

1

问题是您的设备有不同的物理尺寸。由于投影屏幕可能不可见,但这是唯一可能的原因。

密度无关意味着您的小部件在不同的屏幕密度之间共享相同的物理尺寸。无论是hdpi还是ldpi设备,在任何设备上,您希望成为XX dp的尺寸是YY厘米。

现在,由于您的设备在物理尺寸上有所不同,因此您会发现一个设备上的小部件之间有更大的空间,因为它的屏幕更大。虽然小部件与其他设备具有相同的物理大小,但仍留有更多空闲空间。

一种解决方案是使用TextView,它可以自动调整其可用空间上的文本大小,如this one

+0

谢谢,我结束了正常和小屏幕的单独尺寸。 –