我是新来的,所以对于可能违反该平台规则的任何错误,我深表歉意。
我在用背景图片填充Android应用程序时遇到问题。我尝试遵循this,但出现渲染异常。
不使用[SizedBox]类的代码如下:
return Scaffold(
appBar: new AppBar(title: Text("Progresso nel edilizia")),
body: SingleChildScrollView(
child: Container(
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage('assets/login_background.jpg'),
fit: BoxFit.cover
)
),
child: LoginBody(),
)
),
);
答案 0 :(得分:0)
尝试下面的代码
ui <- fluidPage(
titlePanel("Dynamically generated user interface components"),
fluidRow(
selectInput("output_type",
label = "Select type of output",
selected = "table",
choices = c("table", "barplot", "graph")
),
uiOutput("diff_outputs")
)
)
server <- function(input, output){
output$table <- renderTable({head(women)})
output$barplot <- renderPlot({barplot(women$height)})
output$scatterplot <- renderPlot({plot(women$height ~ women$weight)})
output$diff_outputs <- renderUI({
if (is.null(input$output_type))
return()
switch(
input$output_type,
"table" = tableOutput("table"),
"barplot" = plotOutput("barplot"),
"graph" = plotOutput("scatterplot")
)
})
}
shinyApp(ui = ui, server = server)
答案 1 :(得分:0)
尝试此操作,但请确保所使用的图像具有正确的宽高比以适合高度。
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: new AppBar(title: Text("Progresso nel edilizia")),
body: SingleChildScrollView(
child: Container(
height: MediaQuery.of(context).size.height,
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage('assets/login_background.jpg'),
fit: BoxFit.fitHeight)),
child: Container(),
)),
);
}
答案 2 :(得分:0)
在背景上使用屏幕的整个宽度和高度来将堆栈与容器一起使用。像这样:
return Scaffold(
appBar: AppBar(title: Text("Progresso nel edilizia")),
body: Stack(
children: <Widget>[
Container(
width: double.infinity,
height: double.infinity,
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage('assets/login_background.jpg'),
fit: BoxFit.cover,
),
),
),
SingleChildScrollView(
child: LoginBody(),
),
],
),
);