Download

List view background problem

list view has background fill and I dont know how disable it.

Hi, xhn. Seems Epic changed the default style of all Widget elements into dark theme. I spend some time to figure out a solution for C++ project.

Here is the sample class that provide transparent background:

#pragma once

#include "CoreMinimal.h"
#include "Components/ListView.h"
#include "TransparentListView.generated.h"

/**
 * A List View class with transparent background.
 */
UCLASS()
class UTransparentListView : public UListView
{
	GENERATED_BODY()

protected:
	virtual TSharedRef<STableViewBase> RebuildListWidget() override;

protected:
	FTableViewStyle TransparentTableViewStyle;
};

TransparentListView.h

#include "UI/Widget/TransparentListView.h"

TSharedRef<STableViewBase> UTransparentListView::RebuildListWidget()
{
	TSharedRef<SListView<UObject*>> NewWidget = ConstructListView<SListView>();

	FSlateBrush TransparentBrush;
	TransparentBrush.TintColor = FSlateColor(FLinearColor{1.f, 1.f, 1.f, 0.f});

	TransparentTableViewStyle = FAppStyle::Get().GetWidgetStyle<FTableViewStyle>("ListView");
	TransparentTableViewStyle.SetBackgroundBrush(TransparentBrush);
	NewWidget->SetStyle(&TransparentTableViewStyle);

	return NewWidget;
}

TransparentListView.cpp

If you want to adjust the background color, you can add a FLinearColor variable with
UPROPERTY(EditDefaultOnly, BlueprintReadOnly) specifiers. And pass this value into TransparentBrush.TintColor property. It should works as expect.

1 Like

Worked for me, thanks!

I’ll add that you need to add "Slate" and "SlateCore" to the DependencyModuleNames.