0
我有多行標籤(例如100行),文本從底部到頂部滾動,如電影信用。我想模糊該標籤頂部和底部的10%,以便進入和離開的文字模糊不清。我怎樣才能做到這一點?我試圖將某些元素粘在那個位置上並模糊它們,但那不起作用。模糊多行標籤的頂部和底部
我有多行標籤(例如100行),文本從底部到頂部滾動,如電影信用。我想模糊該標籤頂部和底部的10%,以便進入和離開的文字模糊不清。我怎樣才能做到這一點?我試圖將某些元素粘在那個位置上並模糊它們,但那不起作用。模糊多行標籤的頂部和底部
我還沒有看到模糊,但通常文本是褪色。以下是一個如何實現淡入淡出的示例:使用從背景色 - >透明 - >背景色進行線性漸變創建疊加窗格。就像這樣:
public class Main extends Application {
public static void main(String[] args) {
Application.launch(args);
}
@Override
public void start(Stage primaryStage) {
TextArea textArea = new TextArea(
"Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. ");
textArea.setWrapText(true);
StackPane root = new StackPane();
Pane overlay = new Pane();
overlay.setMouseTransparent(true);
Stop[] stops = new Stop[] { new Stop(0.0, Color.WHITE), new Stop(0.25, Color.TRANSPARENT), new Stop(0.75, Color.TRANSPARENT), new Stop(1.0, Color.WHITE) };
LinearGradient linearGradient = new LinearGradient(0, 0, 0, 1, true, CycleMethod.NO_CYCLE, stops);
overlay.setBackground(new Background(new BackgroundFill(linearGradient, null, null)));
root.getChildren().addAll(textArea, overlay);
Scene scene = new Scene(root, 300, 100);
primaryStage.setScene(scene);
primaryStage.show();
}
}
如果你堅持模糊,您可以使用snapshot功能,創建文本的快照,圖像模糊,並把它放在文本的頂部。
這是什麼意思'不起作用?你能提供代碼和截圖嗎? – 2015-03-02 15:23:13