GVKun编程网logo

使用自定义CSS时,JavaFX表上的滚动条会留下空白区域(css自定义滚动条样式)

11

此处将为大家介绍关于使用自定义CSS时,JavaFX表上的滚动条会留下空白区域的详细内容,并且为您解答有关css自定义滚动条样式的相关问题,此外,我们还将为您介绍关于android–工具栏在Recyc

此处将为大家介绍关于使用自定义CSS时,JavaFX表上的滚动条会留下空白区域的详细内容,并且为您解答有关css自定义滚动条样式的相关问题,此外,我们还将为您介绍关于android – 工具栏在RecyclerView滚动上留下隐藏的空白区域、Android – 显示/隐藏片段留下空白区域、android – 选择栏以点击空白区域.如何避免在点击空白区域时突出显示?、css – JavaFX工具提示自定义的有用信息。

本文目录一览:

使用自定义CSS时,JavaFX表上的滚动条会留下空白区域(css自定义滚动条样式)

使用自定义CSS时,JavaFX表上的滚动条会留下空白区域(css自定义滚动条样式)

一张图片胜过千言万语:

.

正如你所看到我在这张桌子上使用自定义CSS,但我不能填充右上角.我尝试更改滚动窗格的背景而没有结果.

这是实际的CSS:

.table-row-cell {
  -fx-background-color: rgba(71,81,80,0.5);
}

.table-row-cell:hover {
  -fx-background-color: rgba(40,96,93,0.50);
}

.table-row-cell:hover:empty {
  -fx-background-color: rgba(71,0.5);
}

.table-row-cell .table-cell {
  -fx-border-width: 0px;

}

.table-view {
  -fx-border-color: rgba(1,11,12,1);
  -fx-background-radius: 2;
  -fx-border-width: 1px;
  -fx-border-radius: 2;
  -fx-background-color: rgba(71,0.2);
  -fx-background-insets: 0;
}

.table-view .column-header {
  -fx-background-color: rgba(1,1);
}

.scroll-bar {
  -fx-background-color: rgba(1,1);
}

.scroll-bar .increment-button:hover {
  -fx-background-color: rgba(1,1);
}

.scroll-bar .decrement-button:hover {
  -fx-background-color: rgba(1,1);
}

.scroll-bar .thumb {
  -fx-background-color: rgba(71,0.5);
}

任何帮助将非常感激.

解决方法

我最终找到了解决方法,感谢@James_D帮助我找到解决方案.

该角不是滚动窗格的一部分,而是table.view标题.因此,您可以使用此代码更改背景.

填充是必要的,因为它在没有它的情况下在右侧留下一条奇怪的白线.

.table-view .column-header-background .filler {
  -fx-background-color: rgba(1,1);
  -fx-padding: 1em;
}

如果您找到更好的方法来实现这一目标,欢迎您的回答.

android – 工具栏在RecyclerView滚动上留下隐藏的空白区域

android – 工具栏在RecyclerView滚动上留下隐藏的空白区域

我试图在RecyclerView滚动条上隐藏我的工具栏,到目前为止它似乎已经隐藏了,但是它留下了一个白色的空白.我很确定这与我的MainActivity的布局和FrameLayout中的片段的叠加有关.

这是我的activity_main.xml.我需要FrameLayout,因为我在导航抽屉中选择了一个项目来加载不同的片段.

<android.support.v4.widget.DrawerLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/drawer"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:elevation="7dp"
    tools:context=".MainActivity"
    android:fitsSystemWindows="true">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <include layout="@layout/toolbar" />

        <FrameLayout
        android:id="@+id/container"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#FFFFFF" />

    </LinearLayout>

    <android.support.design.widget.NavigationView
        android:id="@+id/navigation_view"
        android:layout_height="match_parent"
        android:layout_width="match_parent"
        android:layout_gravity="start"
        app:headerLayout="@layout/header"
        app:menu="@menu/drawer" />

</android.support.v4.widget.DrawerLayout>

这里是片段中包含RecyclerView的代码.

...
@Override
    public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View v = inflater.inflate(R.layout.fragment_main,container,false);

        getActivity().setTitle("Unit One");

        rv = (RecyclerView) v.findViewById(R.id.rv);
        rv.setHasFixedSize(true);

        llm = new linearlayoutmanager(getActivity());
        rv.setLayoutManager(llm);

        initializeData();
        initializeAdapter();

        rv.addOnScrollListener(showHidetoolbarListener = new RecyclerViewUtils.ShowHidetoolbarOnScrollingListener(MainActivity.toolbar));

        if (savedInstanceState != null) {
            showHidetoolbarListener.onRestoreInstanceState((RecyclerViewUtils.ShowHidetoolbarOnScrollingListener.State) savedInstanceState
                    .getParcelable(RecyclerViewUtils.ShowHidetoolbarOnScrollingListener.SHOW_HIDE_TOOLBAR_LISTENER_STATE));
        }

        return v;
    }

    @Override
    public void onSaveInstanceState(Bundle outState) {
        outState.putParcelable(RecyclerViewUtils.ShowHidetoolbarOnScrollingListener.SHOW_HIDE_TOOLBAR_LISTENER_STATE,showHidetoolbarListener.onSaveInstanceState());
        super.onSaveInstanceState(outState);
    }

最后,fragment_main.xml中的RecyclerView布局:

<android.support.v7.widget.RecyclerView
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:paddingLeft="8dp"
        android:paddingRight="8dp"
        android:orientation="vertical"
        android:scrollbars="vertical"
        android:id="@+id/rv" />

这是对我other post的跟进,但是我想问一个新的问题,因为我这次尝试了different method(不要阅读整篇文章,请看底部的编辑).这是他的MainActivity和实际的scrolling listener code.

我很抱歉,如果这似乎我说“这是我的狗屎去解决它”,但我花了将近两个小时寻找可能的解决方案.一如既往,我非常感谢你的帮助.

解决方法

我认为,您用来为工具栏设置动画的translateY只会移动屏幕上绘制的内容而不是视图位置本身.这意味着持有工具栏的视图仍占据线性布局顶部的空间.

使用他在main_activity.xml中使用的相同布局.
您还可以使用FrameLayout.重要的是你将工具栏放在RecyclerView的顶部(下面是xml),并在RecyclerView上添加一个等于工具栏高度的顶部填充.

<android.support.v7.widget.RecyclerView
  android:clipToPadding="false"
  android:paddingTop="?attr/actionBarSize" />

<android.support.v7.widget.Toolbar
  ..... />

Android – 显示/隐藏片段留下空白区域

Android – 显示/隐藏片段留下空白区域

鉴于:

>屏幕上有两个垂直放置的元素(ViewPager和Fragment)
>第一个当前选定片段(ViewFlipper)中的操作在顶部片段中基于文本和基于WebView的视图之间切换,并隐藏/显示底部片段.

观测到的:

>隐藏底部片段会留下底部片段所在的空白区域.

我尝试了Relative和LinearLayout(顶部片段设置为weight = 1)但是底部片段被移除后都没有效果我底部仍然有空的空间

这是顶级布局文件:

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

<android.support.v4.view.ViewPager
    android:id="@+id/pager"
    android:layout_width="fill_parent"
    android:layout_height="0dip" android:layout_weight="1"/>

<!-- This gets replaced with appropriate fragment at run time -->
<LinearLayout
    android:id="@+id/scrollFragmentPlaceholder"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:minHeight="110dip" />
</LinearLayout>

这是切换片段的代码

Fragment scroll = getSupportFragmentManager().findFragmentById(R.id.scrollFragment);
    if (scroll.isHidden() == isWebView)
        return; // already handled,do nothing
    FragmentTransaction tr = getSupportFragmentManager().beginTransaction();
    if (scroll != null && scroll.isAdded()) {
        if (isWebView) {
            tr.hide(scroll);
        } else
            tr.show(scroll);
    }
    tr.commit();

以下是它的外观:

解决方法

一个月后,我想出了如何做到这一点.事实证明,仅仅隐藏片段是不够的,基本上我需要隐藏/显示包含片段的shell.它仍然是最初在XML中定义的LinearLayout.实际上,在原始布局上设置可见性以显示/隐藏片段就足够了.所以问题中的代码现在看起来像这样:
public void onJobViewToggled(final boolean isWebView) {
    if (isFinishing())
        return;
    final Fragment scroll = getSupportFragmentManager().findFragmentById(R.id.scrollFragment);
    if (scroll.isHidden() == isWebView)
        return; // already handled,do nothing
    final FragmentTransaction tr = getSupportFragmentManager().beginTransaction();
    if (scroll != null && scroll.isAdded()) {
        if (isWebView) {
            tr.hide(scroll);
            // shell is the original placeholder
            shell.setVisibility(View.GONE);
        } else {
            tr.show(scroll);
            shell.setVisibility(View.VISIBLE);
        }
    }
    tr.commit();
}

请注意,您仍然希望显示/隐藏片段以使其工作

android – 选择栏以点击空白区域.如何避免在点击空白区域时突出显示?

android – 选择栏以点击空白区域.如何避免在点击空白区域时突出显示?

当我们点击每个栏上方的空白区域时,会选择栏.在这里,我需要避免在单击空白区域时突出显示.

enter image description here

解决方法

当单击它们上方的空白区域时,目前无法阻止条形图突出显示.

你唯一能做的就是减少吧台上方的空白空间.

css – JavaFX工具提示自定义

css – JavaFX工具提示自定义

我使用 JavaFX遇到了以下问题.

使用样式表重新定义工具提示样式适用于Java Scene Builder.

使用与场景构建器生成的FXML文件中包含的相同样式表重新定义eclipse中执行时的工具提示样式

<stylesheets>
    <URL value="@../style/myCSS.css" />
</stylesheets>

不起作用(任何其他属性重新定义工作).

使用代码指令在相同的样式表中重新定义eclipse中执行的工具提示样式:

scene.getStylesheets().add(this.getClass().getResource("/style/myCSS.css").toExternalForm());

工作正常.

使用的样式表(myCSS.css):

.tooltip {
    -fx-background-radius: 2 2 2 2;
    -fx-background-color: linear-gradient(#FFFFFF,#DEDEDE);
}

.page-corner {
    -fx-shape: " ";
}

AnchorPane {
    -fx-background-color: firebrick;
}

使用FXML文件:

<AnchorPane id="AnchorPane" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefheight="91.0" prefWidth="200.0" xmlns:fx="http://javafx.com/fxml">
  <children>
    <Button layoutX="72.0" layoutY="35.0" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" text="Button">
      <tooltip>
        <Tooltip text="Tootip Text" />
      </tooltip>
    </Button>
  </children>
  <stylesheets>
    <URL value="@../style/myCSS.css" />
  </stylesheets>
</AnchorPane>

编辑:换句话说,我想要在FXML文件中声明我的样式表.这样做似乎适用于除工具提示之外的任何属性重新定义(在本例中为AnchorPane背景颜色).

解决方法

您尝试为Tooltip设置的CSS属性仅与扩展 Region类的JavaFX类相关. Tooltip是PopupControl类的子类,因此具有更有限的CSS属性库. Here’s a link to a list of available CSS properties for Tooltip.该站点是JavaFX CSS属性的最佳参考.

今天关于使用自定义CSS时,JavaFX表上的滚动条会留下空白区域css自定义滚动条样式的讲解已经结束,谢谢您的阅读,如果想了解更多关于android – 工具栏在RecyclerView滚动上留下隐藏的空白区域、Android – 显示/隐藏片段留下空白区域、android – 选择栏以点击空白区域.如何避免在点击空白区域时突出显示?、css – JavaFX工具提示自定义的相关知识,请在本站搜索。

本文标签: