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
实施了.)
在Xamarin.Forms每个View
有两个属性HorizontalOptions
和VerticalOptions
.两者都是类型LayoutOptions
,可以具有以下值之一:
LayoutOptions.Start
LayoutOptions.Center
LayoutOptions.End
LayoutOptions.Fill
LayoutOptions.StartAndExpand
LayoutOptions.CenterAndExpand
LayoutOptions.EndAndExpand
LayoutOptions.FillAndExpand
显然,它控制父视图上视图的对齐方式.但每个选项的行为究竟如何呢?和Fill
后缀有Expand
什么区别?
给定一个视图如何在其中获取子视图?
所以我有一个自定义View和调试器显示mChildren
其他7个视图.我需要一种方法来访问这些视图,但似乎没有公共API来执行此操作.
有什么建议?
编辑:
我的自定义视图继承自 AdapterView
我正在寻找一种简单的方法来立即从超视图中删除所有子视图,而不是逐个删除它们.
//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) 在python 2.7中,我们获得了可用的字典视图方法.
现在,我知道以下的利弊:
dict.items()
(和values
,keys
):返回一个列表,这样你就可以实际存储的结果,dict.iteritems()
(等等):返回一个生成器,这样你就可以迭代生成逐个生成的每个值. 什么是dict.viewitems()
(等)?他们有什么好处?它是如何工作的?什么是观点?
我读到视图总是反映字典中的变化.但是从性能和内存的角度来看它是如何表现的呢?有什么利弊?
我有一个视图布局 -
<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)
我想循环遍历我的数据模型,并将包含第一个布局的多个视图注入主布局.我知道我可以通过在代码中完全构建控件来实现这一点,但我想知道是否有一种方法可以动态构建视图,以便我可以继续使用布局而不是将所有内容都放在代码中.
每当出现软件键盘时,它都会调整背景图像的大小.请参阅下面的屏幕截图:
如你所见,背景有点挤压.任何人都可以了解为什么背景调整大小?
我的布局如下:
<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) 如果数据库中存在某个View,我需要执行一些SQL代码.我如何检查View是否存在?
编辑:正在使用的DBMS是Microsoft SQL Server
可能重复:
性能中视图和表之间的差异
SQL中视图和表之间的主要区别是什么.使用视图而不是表是否有任何优势.
有没有直接测量文字高度的方法?我现在这样做的方法是使用Paint measureText()
来获取宽度,然后通过试验和错误找到一个值来获得近似高度.我也一直在搞乱FontMetrics
,但所有这些似乎都是近似的方法.
我正在尝试扩展不同分辨率的东西.我可以做到,但我最终得到了令人难以置信的冗长代码,并通过大量计算来确定相对大小.我讨厌它!一定有更好的方法.
view ×10
android ×5
layout ×2
sql ×2
autoresize ×1
c# ×1
database ×1
dictionary ×1
dynamic ×1
graphics ×1
macos ×1
python ×1
sql-server ×1
swift ×1
xamarin ×1