【问题标题】:Xamarin Android How to do Scrollview with Percents HeightsXamarin Android 如何使用百分比高度进行滚动视图
【发布时间】:2016-11-26 17:15:23
【问题描述】:

Android 视图似乎很挑剔。看起来滚动视图的高度需要为:

height ="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" /> ...

这里只是一个样本,因为它很长。那个图片按钮我想占据屏幕的 30% 左右。

【问题讨论】:

    标签: xml xamarin xamarin.android


    【解决方案1】:

    为什么这些信息不存在。所以 dp 代表与密度无关的像素。基本上,它们已经正确缩放以实现它,因此根据我的理解百分比,所有视图看起来都相同。如果有人有更多信息,请随意。我以为它代表十像素。

    因此,选择高度 500dp 对于所有设备应该看起来都一样。作为一个没有物理多台设备的人,我总是倾向于观看百分比,但在某些情况下,这似乎不是完全必要的。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-09-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多