2014-02-20 40 views
0

这是为了增加相同的空间视图布局之间的解决方案: make same space between button in linearlayout让按键之间的同一个空间中Horizo​​ntalScrollView

但是,让我们说我们有很多项目,我们需要把他们HorizontalScrollView为手机设备。

<HorizontalScrollView 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" > 

    <LinearLayout 
     android:id="@+id/shareLinearLayout" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/btnRequestAPrescriptionRefill" 
     android:layout_marginTop="10dp" > 

     <Button 
      android:id="@+id/btnFacebook" 
      android:layout_width="50dp" 
      android:layout_height="50dp" 
      android:background="@drawable/btn_facebook" /> 

     <View 
      android:layout_width="0dp" 
      android:layout_height="50dp" 
      android:layout_weight="1" /> 

     ... 

    </LinearLayout> 
</HorizontalScrollView> 

该解决方案对手机工作正常,但在平板电脑中,我们有一个大屏幕大小,按钮之间的空间不工作。按钮只是粘在一起,没有我们创建的空间:

<View 
    android:layout_width="0dp" 
    android:layout_height="50dp" 
    android:layout_weight="1" /> 

有没有解决方法?

回答

1

滚动视图将其大小调整为其内容视图(线性布局),但是当屏幕足够大时您希望以其他方式使用,您希望内容视图将其大小调整为滚动视图。这有点矛盾。

唯一的方法是为您的LinearLayout指定一个minWidth属性。

android:minWidth="200dp" 

这是一个痛苦的对接,因为你可能需要在运行时设置它,或有不同的屏幕分辨率您的XML的很多版本。

也许另一种大屏幕分辨率的方法是在没有滚动视图的情况下提供不同的XML。

+0

谢谢你的提示。看来你是对的。这在某种程度上是矛盾的,我必须用多个XML来处理它。 +1。 – Ali

相关问题