2016-11-26 33 views
0

Android的意见似乎是finicky。这似乎是滚动视图必须高度:Xamarin Android如何使用百分比高度滚动查看

高度=“WRAP_CONTENT”

才能正常工作,但这打乱了,因为我之前使用的想法重量总和,它当它是match_parent时占据了整个屏幕。无论如何仍然有滚动视图内的列表视图内的项目的百分比?或者选择一个例子,如果可能的话。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="#DDDDDD" 
    android:descendantFocusability="beforeDescendants" 
    android:focusable="false" 
    android:focusableInTouchMode="true" 
    android:weightSum="100"> 
    <ScrollView 
     android:layout_width="match_parent" 
     android:fillViewport="true" 
     android:layout_height="wrap_content"> 
     <LinearLayout 
      android:orientation="vertical" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:weightSum="100"> 
      <ImageButton 
       android:src="@android:drawable/ic_menu_gallery" 
       android:layout_width="match_parent" 
       android:layout_height="0dp" 
       android:id="@+id/image" 
       android:scaleType="fitXY" 
       android:layout_weight="30" /> ... 

这里只是一个样本,因为它很长。该图像按钮Id喜欢占用30%左右的屏幕。

回答

0

为什么这个信息没有在哪里。所以dp代表不依赖于密度的像素。基本上他们已经适当地扩大规模,所以所有的观点都会根据我理解的百分比来看。如果有人有更多的信息,请随时感受。我认为它代表了十亿像素。

所以选择高度500dp对于所有设备看起来应该是一样的。作为一个没有物理多个设备的人,我总是依靠视图中的百分比,但是对于某些情况来说,这似乎不是完全必要的。