我在一个需要stackview的应用程序中.但是我必须实现水平滑动以在stackview项和UI外观之间切换为正常的.请帮我搞定.
我已经检查了这个链接.
但在它中UI只是一个封面流程.我想让UI看起来像stackview一样.
我想在我的应用程序中创建可滑动的堆栈视图.我附上以下视图.
在该堆栈视图中,我可以通过滑动项目位置来删除特定项目吗?

请提供任何参考示例或教程.
我有一个 tableview,我想UIStackView在每个部分标题中都有一个。现在,我想给这个 stackView 做一点填充:特别是,我希望 stackView 占据整个空间,除了每边 2px 。这可能吗?这是我尝试过的:
override func tableView(tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let sNumber = UILabel()
sNumber.backgroundColor = UIColor.yellowColor()
sNumber.text = String(section)+". "
let lbl = UILabel()
lbl.backgroundColor = UIColor.cyanColor()
lbl.text = (detailItem![section]["canary"] as! String)
let lbl2 = UILabel()
lbl2.backgroundColor = UIColor.greenColor()
lbl2.text = (detailItem![section]["tbd"] as! String)
let stackView = UIStackView()
stackView.axis = UILayoutConstraintAxis.Horizontal
stackView.distribution = UIStackViewDistribution.FillProportionally
stackView.alignment = UIStackViewAlignment.Center
stackView.spacing = 10
let margins = stackView.layoutMarginsGuide
stackView.leadingAnchor.constraintEqualToAnchor(margins.leadingAnchor, constant: 2).active = true …Run Code Online (Sandbox Code Playgroud) 是否有必要强制使用自动布局来仅使用 stackview 假设我已经制作了没有自动布局的整个项目,现在对于特定屏幕我必须使用 Stackview 来平均划分视图内的标签数量。有什么解决办法吗..
问题
实际上我必须自定义一个没有自动布局的旧项目,现在我必须只修改一个屏幕,它不需要任何约束,而只是像 uitablecell 一样的 stackview,每个单元格中有 8 个标签等分。
我知道我们可以通过计算帧运行时间来做到这一点,但是还有其他方法可以做到吗?
我正在尝试构建一个 stackview 小部件,它在滑动时应该显示不同的数据。到目前为止,一切正常,但是当我想接收小部件中单击的卡的索引时,我总是得到一个额外的或“null”的操作。我已经尝试了几种解决方法,但没有一个在我的应用程序中起作用。我还设置了一个全新的应用程序,只是为了使这项工作完全隔离。但在这里我得到了完全相同的行为。
我尝试传递索引的几种解决方法:
我观察到,在生成的 exampleData 列表中的正确位置调用 getViewAt 函数之前,它会被多次调用,位置(p0)为“0”...但我不知道这是否会导致空值在 onReceive 函数中,当单击卡片时。
这是我的编码:
清单.xml
<service android:name=".ExampleWidgetService"
android:permission="android.permission.BIND_REMOTEVIEWS">
</service>
Run Code Online (Sandbox Code Playgroud)
组件布局
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<StackView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/stackview">
</StackView>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/empty_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:textColor="#ffffff"
android:textStyle="bold"
android:text="empty"
android:textSize="20sp" />
</FrameLayout>
Run Code Online (Sandbox Code Playgroud)
小部件项条目
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="200dp"
android:layout_height="200dp"
android:text="Icon"
android:id="@+id/newwidgetentry">
</TextView> …Run Code Online (Sandbox Code Playgroud) 然而,我有一个UIStackView,第一个视图subViews是 aUILabel并且它没有相应地调整它的大小。
我的代码如下;
private let stackView: UIStackView = {
let view = UIStackView()
view.translatesAutoresizingMaskIntoConstraints = false
view.axis = .horizontal
view.distribution = .fillProportionally
view.alignment = .trailing
view.spacing = 8
return view
}()
Run Code Online (Sandbox Code Playgroud)
当然,我添加了以下内容subViews;init
stackView.addArrangedSubview(currentBidLabel)
stackView.addArrangedSubview(seperator)
stackView.addArrangedSubview(adCreatedAtLabel)
stackView.addArrangedSubview(moreButton)
Run Code Online (Sandbox Code Playgroud)
我目前的结果如下图所示;
我正在寻找的结果如下;
我有一个包含 2 个标签的 StackView。一种是普通文本,另一种是 FontAwesome Icon。
无论如何,两个标签都没有在 StackView 内垂直居中。这是他们的代码:
样式:
<Style x:Key="FAIconedLabel" TargetType="Label">
<Setter Property="TextColor" Value="White"/>
<Setter Property="FontSize" Value="40" />
<Setter Property="Margin" Value="0" />
</Style>
<Style x:Key="EmailLabel" TargetType="Label">
<Setter Property="TextColor" Value="White"/>
<Setter Property="FontSize" Value="20" />
</Style>
Run Code Online (Sandbox Code Playgroud)
和视图本身
<!-- Top Right -->
<Grid BackgroundColor="{StaticResource LamaControlGray}"
RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent,
Property=Width,Factor=1,Constant=-400}"
RelativeLayout.WidthConstraint="{ConstraintExpression
Type=RelativeToParent,Property=Width,Factor=0,Constant=400}"
RelativeLayout.HeightConstraint="{ConstraintExpression
Type=RelativeToParent,Property=Height,Factor=0,Constant=40}" >
<StackLayout Orientation="Horizontal" HorizontalOptions="End" VerticalOptions="FillAndExpand" BackgroundColor="Red">
<Label x:Name="LblUserEmail" Margin="0,0,10,0" Text="{Binding UserEmail}" VerticalOptions="FillAndExpand" Style="{StaticResource EmailLabel}"/>
<fal:FontAwesomeLabel Text="{Binding SettingsIcon}" BackgroundColor="Green" VerticalOptions="CenterAndExpand" Style="{StaticResource FAIconedLabel}" />
</StackLayout>
</Grid>
Run Code Online (Sandbox Code Playgroud)
我在这里想念什么吗?
我添加了一个 BackgroundColor …
我正在以编程方式创建一个带有自定义单元格的表格视图。我想在自定义单元格中使用带有排列子视图的堆栈视图。然而,我所有的努力都失败了。首先,是否有可能做到这一点?
其次,我将代码放在:
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: "cellId")
Run Code Online (Sandbox Code Playgroud)
我正在使用此代码创建堆栈视图:
let thestack: UIStackView = {
let sv = UIStackView()
sv.distribution = .fillEqually
sv.axis = .vertical
sv.spacing = 8
return sv
}()
Run Code Online (Sandbox Code Playgroud)
但是我无法将排列的子视图添加到此之外,在添加子视图(thestack)并列出所有约束之后 - 我的数据均未显示在自定义单元格中。任何帮助,将不胜感激。
我已经完成了Qt文档:Qt StackView但我仍然无法弄清楚我做错了什么,因为我的代码应该产生淡入/淡出动画,但我得到的只是内容之间的瞬间闪烁.我希望我的描述充分而清晰.
StackView {
id: stackView
anchors.fill: parent
delegate: StackViewDelegate {
function transitionFinished(properties)
{
properties.exitItem.opacity = 1
}
property Component pushTransition: StackViewTransition {
PropertyAnimation {
target: enterItem
property: "opacity"
from: 0
to: 1
duration: 10
}
PropertyAnimation {
target: exitItem
property: "opacity"
from: 1
to: 0
duration: 10
}
}
}
initialItem: Item {
width: parent.width
height: parent.height
ListView {
model: pageModel
anchors.fill: parent
delegate: AndroidDelegate {
text: title
onClicked: stackView.push(Qt.resolvedUrl(page))
}
}
}
}
Run Code Online (Sandbox Code Playgroud) 我想在加载qml文件时启用TextField焦点。但是,它不起作用。加载TestUi.qml文件后,我放了一些按钮,并使用了onClick方法(我做了receiveView.focus = true),效果很好。问题在于,首次加载视图时未启用默认焦点。
TestUi.qml
import QtQuick 2.0
import QtQuick.Controls 2.1
import QtQuick.Layouts 1.0
Page {
function init() {
recipientView.focus = true;
}
TextField {
id: recipientView
Layout.fillWidth: true
font.pixelSize: 18
inputMethodHints: Qt.ImhNoPredictiveText | Qt.ImhEmailCharactersOnly
focus: true
placeholderText: "Email"
}
}
Run Code Online (Sandbox Code Playgroud)
main.qml
onComposeBtnClicked: {
rootStackView.push(test)
test.init()
}
TestUi {
id: test
visible: false
}
Run Code Online (Sandbox Code Playgroud) stackview ×10
swift ×4
android ×3
ios ×2
qml ×2
qt ×2
android-ui ×1
autolayout ×1
autoresize ×1
cell ×1
focus ×1
java ×1
listview ×1
transitions ×1
uitableview ×1
xamarin ×1