标签: view

Android:为什么视图没有maxHeight?

View有一个minHeight但不知何故缺少一个maxHeight:

我想要实现的是让一些项目(视图)填满ScrollView.当有1..3项时,我想直接显示它们.意味着它ScrollView具有1,2或3个项目的高度.

当有4个或更多项目我希望ScrollView停止扩展(因此a maxHeight)并开始提供滚动.

但是,遗憾的是没有办法设置maxHeight.因此,我可能必须以ScrollView编程方式WRAP_CONTENT将高度设置为有1..3项3*sizeOf(View)时的高度,并将高度设置为有4个或更多项时的高度.

任何人都可以解释为什么没有maxHeight提供,什么时候已经有minHeight

(顺便说一下:有些观点,比如ImageView已经maxHeight实施了.)

layout android view autoresize

168
推荐指数
7
解决办法
11万
查看次数

Xamarin.Form的LayoutOptions有什么区别,特别是Fill和Expand?

在Xamarin.Forms每个View有两个属性HorizontalOptionsVerticalOptions.两者都是类型LayoutOptions,可以具有以下值之一:

  • LayoutOptions.Start
  • LayoutOptions.Center
  • LayoutOptions.End
  • LayoutOptions.Fill
  • LayoutOptions.StartAndExpand
  • LayoutOptions.CenterAndExpand
  • LayoutOptions.EndAndExpand
  • LayoutOptions.FillAndExpand

显然,它控制父视图上视图的对齐方式.但每个选项的行为究竟如何呢?和Fill后缀有Expand什么区别?

c# layout view xamarin xamarin.forms

161
推荐指数
2
解决办法
4万
查看次数

Android - 让孩子进入视图?

给定一个视图如何在其中获取子视图?

所以我有一个自定义View和调试器显示mChildren其他7个视图.我需要一种方法来访问这些视图,但似乎没有公共API来执行此操作.

有什么建议?

编辑:

我的自定义视图继承自 AdapterView

android view

160
推荐指数
5
解决办法
16万
查看次数

如何在Swift中删除视图的所有子视图?

我正在寻找一种简单的方法来立即从超视图中删除所有子视图,而不是逐个删除它们.

//I'm trying something like this, but is not working
let theSubviews : Array = container_view.subviews
for (view : NSView) in theSubviews {
    view.removeFromSuperview(container_view)
}
Run Code Online (Sandbox Code Playgroud)

我错过了什么?

UPDATE

我的应用有一个主要的container_view.我必须添加不同的其他视图作为子视图,container_view以提供一种导航.

因此,当单击按钮以"打开"特定页面时,我需要删除所有子视图并添加新视图.

更新2 - 工作解决方案(OS X)

我猜Apple修了它.

现在比以往任何时候都更容易,只需致电:

for view in containerView.subviews{
    view.removeFromSuperview()
}
Run Code Online (Sandbox Code Playgroud)

macos view swift

159
推荐指数
11
解决办法
13万
查看次数

什么是字典视图对象?

在python 2.7中,我们获得了可用的字典视图方法.

现在,我知道以下的利弊:

  • dict.items()(和values,keys):返回一个列表,这样你就可以实际存储的结果,
  • dict.iteritems() (等等):返回一个生成器,这样你就可以迭代生成逐个生成的每个值.

什么是dict.viewitems()(等)?他们有什么好处?它是如何工作的?什么是观点?

我读到视图总是反映字典中的变化.但是从性能和内存的角度来看它是如何表现的呢?有什么利弊?

python dictionary view

149
推荐指数
5
解决办法
6万
查看次数

Android - 动态地将视图添加到视图中

我有一个视图布局 -

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:padding="0px"
    android:orientation="vertical">

    <TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:id="@+id/items_header"
        style="@style/Home.ListHeader" />

    <TextView 
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:id="@+id/items_none"
        android:visibility="gone"
        style="@style/TextBlock"
        android:paddingLeft="6px" />

    <ListView 
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:id="@+id/items_list" />


</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

我想要做的是,在我的主要活动中使用这样的布局

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:padding="0px"
    android:id="@+id/item_wrapper">
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

我想循环遍历我的数据模型,并将包含第一个布局的多个视图注入主布局.我知道我可以通过在代码中完全构建控件来实现这一点,但我想知道是否有一种方法可以动态构建视图,以便我可以继续使用布局而不是将所有内容都放在代码中.

android view dynamic android-layout

141
推荐指数
5
解决办法
25万
查看次数

软件键盘在Android上调整背景图像的大小

每当出现软件键盘时,它都会调整背景图像的大小.请参阅下面的屏幕截图:

如你所见,背景有点挤压.任何人都可以了解为什么背景调整大小?

我的布局如下:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/page_bg"
    android:isScrollContainer="false"
>
    <LinearLayout android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:layout_width="fill_parent"
    >
        <EditText android:id="@+id/CatName"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:inputType="textCapSentences"
            android:lines="1"
        />
        <Button android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/save"
            android:onClick="saveCat"
        />
    </LinearLayout>
    <ImageButton
        android:id="@+id/add_totalk"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:background="@null"
        android:src="@drawable/add_small"
        android:scaleType="center"
        android:onClick="createToTalk"
        android:layout_marginTop="5dp"
    />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

android view android-linearlayout

127
推荐指数
8
解决办法
6万
查看次数

如何检查数据库中是否存在视图?

如果数据库中存在某个View,我需要执行一些SQL代码.我如何检查View是否存在?

编辑:正在使用的DBMS是Microsoft SQL Server

sql database sql-server stored-procedures view

122
推荐指数
6
解决办法
16万
查看次数

sql中View和table之间的区别

可能重复:
性能中视图和表之间的差异

SQL中视图和表之间的主要区别是什么.使用视图而不是表是否有任何优势.

sql view

120
推荐指数
5
解决办法
25万
查看次数

测量在Canvas(Android)上绘制的文本高度

有没有直接测量文字高度的方法?我现在这样做的方法是使用Paint measureText()来获取宽度,然后通过试验和错误找到一个值来获得近似高度.我也一直在搞乱FontMetrics,但所有这些似乎都是近似的方法.

我正在尝试扩展不同分辨率的东西.我可以做到,但我最终得到了令人难以置信的冗长代码,并通过大量计算来确定相对大小.我讨厌它!一定有更好的方法.

graphics android view android-canvas

119
推荐指数
4
解决办法
9万
查看次数