Tag: 布局

具有自定义CellFactory的ListView修剪不可见节点

我的布局问题 我有一个ListView问题,我不知道是否是因为我缺less一些知识,或者如果我的方法有缺陷。 不得不承认,我还不清楚JavaFX在很多可能的情况下如何处理布局。 上面的屏幕截图显示了我使用完全相同的代码得到两次的结果,只是在第二个屏幕上显示了用于debugging 的可见形状 。 由CellFactory扩展Group涉及的各个类,我尝试与其他一些Parent没有太多的成功到目前为止。 如何重现 我没有分享我的StarShape , StarRow和其他一些misc类(如果需要我很乐意),我写了一个样例来重现这个问题。 这个类扩展了Application并覆盖了start(…)方法,如下所示: @Override public void start(Stage primaryStage) throws Exception { final StackPane root = new StackPane(); final Scene scene = new Scene(root, 400, 600); final ListView<Boolean> listView = new ListView<>(); listView.setCellFactory(this::cellFactory); for (int i = 0; i < 5 ; i++) { listView.getItems().add(true); listView.getItems().add(false); } […]

sw600dp和w600dp之间的区别?

请用简单的方法详细说明sw<N>dp和s<N>dp之间的区别。 我已经研究了屏幕尺寸的完整文档,但是在这两个限定符sw <>和w <>之间混淆了。

居中两个button水平

我试着安排两个button(在他们的图像上工作正常)彼此相邻,并居中水平。 这是我迄今为止: <LinearLayout android:orientation="horizontal" android:layout_below="@id/radioGroup" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal|center"> <Button android:id="@+id/allow" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@id/radioGroup" android:layout_gravity="center_horizontal" android:drawableLeft="@drawable/accept_btn" android:text="Allow"/> <Button android:id="@+id/deny" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_toRightOf="@id/allow" android:layout_below="@id/radioGroup" android:layout_gravity="center_horizontal" android:drawableLeft="@drawable/block_btn" android:text="Deny"/> </LinearLayout> 不幸的是,他们仍然左alignment。 任何帮助表示赞赏! 伊夫 编辑 : 不幸的是迄今没有任何意见或build议。 这就是为什么我尝试用RelativeLayout提供一个简化的,完整的布局: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_centerHorizontal="true"> <TextView android:text="@+id/TextView01" android:id="@+id/TextView01" android:layout_width="wrap_content" android:layout_height="wrap_content"/> <Button android:id="@+id/allow" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@id/TextView01" android:text="Allow"/> <Button android:id="@+id/deny" android:layout_width="wrap_content" […]

左侧主导和主导主导之间的区别?

我一直在iOS中使用Swift中的约束,而大部分的命名约定/文档都是非常自我解释的,但最近困扰我的是两对NSLayoutXAxisAnchor类: leadingAnchor, leftAnchor 随着 trailingAnchor, rightAnchor 当我在我的iOS应用程序中以编程方式设置约束时,我发现我可以完全交换使用这些约束。 如果我使用leadingAnchor,运行应用程序并观察行为,然后使用leftAnchor,运行应用程序并观察行为,它的function完全相同。 我查看了developer.apple.com上的文档,结果甚至完全一样(忽略名称上的差异)。 例如比较leadingAnchor和leftAnchor: “使用这个锚来创build视图的前沿约束,你只能将这个锚与NSLayoutXAxisAnchor锚的一个子集组合起来,你可以把一个leadingAnchor和另一个leadingAnchor,一个尾随锚或者一个centerXAnchor结合起来。参考。” 相比于: “使用这个锚点来创build视图左边缘的约束,你只能将这个锚点与NSLayoutXAxisAnchor锚点的一个子集结合起来,你可以把一个左锚点与另一个左锚点,右锚点或者centerXAnchor组合起来。参考。” 有谁知道这些属性之间是否有意图的区别?

在FrameLayout中的Android中心视图不起作用

我有一个FrameLayout,我有2个控件: – 一个自定义视图,其中绘制一个图像和一些文本 – 一个文本视图与文本 我想要在FrameLayout中居中,但我无法做到这一点。 Texview居中就好了,当我看到它时,我的左右视图保留在左侧。 <FrameLayout android:id="@+id/CompassMap" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" android:gravity="center"> <view class="com.MyView" android:id="@+id/myView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical|center_horizontal" android:visibility="gone"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical|center_horizontal" android:text="CENTERED" /> </FrameLayout> 对Mathias来说,我没有在构造函数中做任何事情,只是简单的 public class MyMapView extends View { private int xPos = 0; private int yPos = 0; private Bitmap trackMap; private Matrix backgroundMatrix; private Paint backgroundPaint; private Bitmap […]

防止内联块div的包装

jsFiddle演示 我想要divs: 包装他们的内容,和 留在原来的关联线,基本上没有包装。 基本上,当桌子不能留在屏幕上的时候,桌子就会叠在一起。 我宁愿他们隐藏在屏幕之外。 我已经尝试添加overflow: hidden; 到主要的布局风格。 我不想修复每个div的宽度。 它需要适应内容。 .layout { -moz-border-radius: 15px; border-radius: 15px; vertical-align: top; display: inline-block; } .layoutbacking { -moz-border-radius: 15px; border-radius: 15px; padding: 5px; margin: 5px; background: #CCCCCC; } <div class="layout" style="background: #222222; width: 100%"> <div> <div class="layout layoutbacking"> <table> <tr> <th>header 1</th> <th>header 2</th> <th>header 3</th> <th>header 4</th> […]

如何获得一个button的高度来匹配另一个元素的高度?

我想把一个button旁边的EditText,我希望他们的高度匹配。 例如,从内置的Android浏览器: Gobutton与EditText字段的高度相同。 我知道我可以在父视图中包装这两个视图,并将它们的高度设置为fill_parent,这将使它们匹配。 不过,我想这样做,而不必给布局一个静态的大小。 我宁愿EditText根据字体大小采取任何需要的高度,然后让它旁边的button匹配任何可能的高度。 这可能与一个XML布局?

如何防止EditText在用户input时自行resize?

我有一个EditText和一个Button设置在同一水平线上彼此相邻。 它看起来不错,除非用户input大量文本, EditText被resize, Button被压扁。 我将EditText和Button设置为layout_width="wrap_content" 。 "fill_parent"弄乱了布局,我不想使用绝对大小,如果我不需要 – 现在它在横向和纵向上看起来都很棒,我只是不希望EditTextresize。 我的布局: <TableLayout android:id="@+id/homelayout" android:layout_width="fill_parent" android:layout_height="fill_parent" > <TableRow> <TextView android:id="@+id/labelartist" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Find artists:" /> </TableRow> <TableRow> <EditText android:id="@+id/entryartist" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="6" android:background="@android:drawable/editbox_background" android:editable="true" android:padding="5px" android:singleLine="true" /> <Button android:id="@+id/okartist" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:layout_marginLeft="10dip" android:layout_weight="1" android:text="Search" /> </TableRow> </TableLayout>

轨3,如何添加一个视图,不使用相同的布局作为rest的应用程序?

我无法find关于如何构build我的应用程序的任何文档或示例,以允许同一控制器中的不同视图使用完全不同的布局和样式表。 我们的应用程序是脚手架,然后我们使用漂亮的发电机生成的意见,然后添加deviseauthentication。 我们有两个模型的视图和控制器:小部件和公司。 我目前有一个布局:layouts / application.html.haml,我没有看到引用任何地方,所以我认为(一个新手),它总是使用命名约定。 我现在需要在同一个控制器中添加几个视图(对于移动浏览器),它们具有不同的样式表和布局(例如,右上angular没有login/注销链接)。 如何做到这一点?

如何在Symfony布局中获取_localevariables?

我在一个拥有2种语言的站点上使用Symfony 2,我想根据用户语言环境语言来改变路由模式! 例: user_login_en: pattern: /en/user/login.html defaults: { _controller: SfErrorsAppBundle:User:login, _locale: en } user_login_fr: pattern: /fr/utilisateur/connexion.html defaults: { _controller: SfErrorsAppBundle:User:login, _locale: fr} 在模板里面,这并不难,我只需要将$ this-> get('session') – > getLocale()从控制器传递给模板。 为了工作,我必须打电话给我的路线: $router->generate('user_login_'.$locale, array()); 但在我的布局,我当然有一个菜单,和侧链,有链接…所以我想要获取localevariables来使用它! 所以我的问题很简单:如何获得“布局”模板内的这个variables? 否则,你有任何想法改变模式取决于语言? 原因是我想为所有用户提供美丽的路线,无论他们是英语还是法语…还有一个search引擎优化的原因!