标签: stretch

如何在Flutter中拉伸图像以适应整个背景(100%高度x 100%宽度)?

我的图像与设备屏幕的宽高比不匹配.我想拉伸图像,使其完全填满屏幕,我不想裁剪图像的任何部分.

CSS具有百分比的概念,因此我可以将高度和宽度设置为100%.但看起来Flutter似乎没有这个概念,只是硬编码高度和宽度是不好的,所以我被卡住了.

这就是我所拥有的(我使用的是Stack,因为我在图像的前景中有一些东西):

Widget background = new Container(
  height: // Not sure what to put here!
  width: // Not sure what to put here!
  child: new Image.asset(
    asset.background,
    fit: BoxFit.fill, // I thought this would fill up my Container but it doesn't
  ),
);

return new Stack(
  children: <Widget>[
    background,
    foreground,
  ],
);
Run Code Online (Sandbox Code Playgroud)

containers image stretch flutter

20
推荐指数
9
解决办法
2万
查看次数

如何获取TextBox以填充可调整大小的列?

我正在尝试使用TextBox来填充可调整大小的列中的可用空间.TextBox是用户控件的一部分:

<UserControl x:Class="TextBoxLayout.FieldControl"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto"/>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>
        <Label Grid.Column="0">Name</Label>
        <TextBox Grid.Column="1"/>
    </Grid>
</UserControl>
Run Code Online (Sandbox Code Playgroud)

此用户控件位于带垂直拆分器的窗口中:

<Window x:Class="TextBoxLayout.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:TextBoxLayout"
    Title="Text box layout" Height="400" Width="600">
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition MinWidth="100"/>
            <ColumnDefinition Width="Auto"/>
            <ColumnDefinition MinWidth="100"/>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition/>
        </Grid.RowDefinitions>

        <local:FieldControl Grid.Column="0" Grid.Row="0" MaxWidth="200" HorizontalAlignment="Left"/>

        <TextBlock Grid.Column="0" Grid.Row="1" Text="Testing"/>

        <GridSplitter Grid.Column="1" Grid.Row="0" Grid.RowSpan="2" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="3"/>

        <TextBlock Grid.Column="2" Grid.Row="0" Grid.RowSpan="2" Text="Testing"/>
    </Grid>
</Window>
Run Code Online (Sandbox Code Playgroud)

问题是TexTBox似乎非常狭窄 - 我想要它做的是填充左列并使用拆分器调整大小.我怎么做?

wpf textbox splitter stretch

17
推荐指数
1
解决办法
4万
查看次数

为什么FontStretch在WPF中不起作用?

我正在尝试在WPF中的TextBlock上设置FontStretch属性,但似乎它不起作用.我尝试过Expanded,Condensed等,但文字外观没有变化.

我正在使用带有Framework 4.0的Windows XP,并使用Verdana和Arial进行了测试.

它仅适用于Windows 7或仅适用于某些特定字体吗?

编辑:如果它不适用于所有字体,是否有支持此功能的字体列表?或者是否可以修改像Verdana/Arial这样的字体来支持它?

.net wpf fonts stretch

16
推荐指数
2
解决办法
1万
查看次数

Android的Phonegap启动画面:未拉伸或9patch

当我的phonegap应用程序启动时,我会弹出一个假的闪屏:

super.setIntegerProperty("splashscreen", R.drawable.splash);
super.loadUrl("file:///android_asset/www/index.html", 500);
Run Code Online (Sandbox Code Playgroud)

我目前有3个不同的splash.png文件:hdpi,mdpdi和ldpi.我的问题是即使在hdpi中,你也会得到480 x 800的设备和480 x 854的其他设备,并且android会拉伸我的启动图像来填充屏幕.

我宁愿让图像保持其纵横比.据我所知,9补丁解决方案不适用于PhoneGap.如果愿意,请告诉我如何!我准备好了.9.png了.所以我能想到的其他解决方案是防止android扩展我的图像.我该怎么办?

谢谢!

screen splash-screen stretch nine-patch cordova

13
推荐指数
2
解决办法
1万
查看次数

Html/Css - 如何让图像拉伸100%宽度的容器,然后在其上显示另一个图像?

我正在努力获得我一起考虑的标题的布局.

这是到目前为止的HTML:

<div id="header">
    <img src="/img/headerBg.jpg" alt="" class="headerBg" />
    <a href="/"><img src="/img/logo.png" alt="Logo" class="logo" /></a>
    <div id="loginBox">
        other code
    </div>
</div>
Run Code Online (Sandbox Code Playgroud)

到目前为止的CSS:

#header {
    height: 130px;
    margin: 5px 5px 0 5px;
    border: #0f0f12 outset 2px;
    border-radius: 15px;
}

#loginBox {
    float: right;
    width: 23.5%;
    height: 128px;
    font-size: 75%;
}

.headerBg {

}

.logo {
    width: 50%;
    height: 120px;
    float: left;
    display: block;
    padding: 5px;
}
Run Code Online (Sandbox Code Playgroud)

我想要完成的是将图像"headerBg.jpg"显示为div"header"的100%宽度,所以基本上它将是div本身的背景.然后将图像"logo.png"和div"loginBox"显示在"headerBg.jpg"上方.

徽标应该浮动到最左端,loginBox浮动到最右边,就像在CSS中一样.

删除图像后,徽标和div被正确放置,但是当引入图像时,它们会在流中的图像之后放置两个浮动项目.

我已经尝试了各种添加和重新配置,但没有一个已经证明可以解决我想要的方式.

我已经在css中添加了图像作为标题div的背景,但它不会以这种方式伸展100%.

有人能够对此提供一些见解吗?

此外,任何涵盖此类内容的教程都将是我收藏的一个很好的补充!

谢谢!

html css image stretch

13
推荐指数
1
解决办法
7万
查看次数

在python中沿水平方向物理拉伸绘图

我想要一个简单的x,y图,用matplotlib在x方向上物理拉伸.
目的是得到一个结果,因为我更容易检测到信号中的特征.

因此,我不想更改任何比例或值或限制.只需更改输出文件中两个网格点之间的距离......

我想在四个子图上做到这一点,之后应该有相同的大小.

提前谢谢......我现在试了好几个小时,我想其中一个人可能会帮助我......

David Zwicker在这个特殊情况下已经解决了我的问题,非常感谢,但总的来说......如果我在这段代码中绘制2个子图:

fig = plt.figure()

ax1 = fig.add_subplot(1,2,1)

plot(u_av,z)

ax2 = fig.add_subplot(1,2,2)

plot(pgrd_av,z)

clf()
Run Code Online (Sandbox Code Playgroud)

并且只想拉伸其中一个.我能做什么?

python plot matplotlib stretch

13
推荐指数
3
解决办法
2万
查看次数

WPF:按可用宽度展开TextBox,但不按内容展开?

我需要一个很好的解决方案,使网格中的TextBox扩展到可用空间,但不会根据文本中的文本长度进行扩展.

我发现的大多数解决方案是制作一个虚拟边框并绑定到它的ActualWidth,但对我来说它是一个hacky解决方案.边界解决方案需要在边界设置一个小的边缘,这是不好的.将其设置为低将导致UI表现得非常奇怪.不喜欢这个解决方案.必须有一个更好的?我想要的是文本框不能随其内容扩展.它不应该那么难.请让我知道如何做到这一点.

编辑:

我注意到的一件奇怪的事情是,以下代码使边框变得更大,然后必须是:

<Grid>
  <Border Name="dummy1" Background="Red" />
  <TextBox Text="23242342343555554234234444444444423423423432344444444" Width="{Binding ActualWidth, ElementName=dummy1}" />
</Grid>
Run Code Online (Sandbox Code Playgroud)

替换边框和文本框顺序使边框很好地适应文本框,但我需要的是相反的.如前所述,将边距(在边框上)设置为至少0.5会使其工作,但结果会有一点麻烦的UI.

wpf textbox stretch width

12
推荐指数
1
解决办法
6227
查看次数

GridView和多余的空间填充

Android上的网格视图布局有问题.我找不到解决方案来消除网格视图中的额外空间.我尝试了很多东西(numColumns,columnWidth,stretchMode,gravity)和建议(来自StackOverflow),但没有任何工作正常.我花了将近8个小时来解决这个问题.这是一个网格视图代码:

<GridView
        android:id="@+id/lookbook_gridview"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:listSelector="@null"
        android:padding="0dip"
        android:layout_margin="0dip"
        android:verticalSpacing="0px"
        android:horizontalSpacing="0px"

        android:numColumns="auto_fit"
        android:columnWidth="160px"
        android:stretchMode="columnWidth"
        android:gravity="center" 
        android:layout_gravity="center"

        android:background="#000"
        android:cacheColorHint="#000"
        android:descendantFocusability="afterDescendants"
        android:layout_alignParentTop="true"
        android:layout_above="@id/buttons">
    </GridView> 
Run Code Online (Sandbox Code Playgroud)

我还试图以编程方式减少额外空间:

private void setGridview()
{  
    GridView gridview = (GridView) findViewById(R.id.lookbook_gridview);
    Display display = ((WindowManager) getSystemService(WINDOW_SERVICE)).getDefaultDisplay();

    int gridSize = display.getWidth();
    int count = gridSize / 160; // image has 160x160 px
    int colWidth = (gridSize / count) - PADDING;

    gridview.setColumnWidth(colWidth);
    gridview.setNumColumns(count);
}
Run Code Online (Sandbox Code Playgroud)

但它仅适用于我的HTC Desire(右),但在模拟器(左)具有相同的显示分辨率和相同的API版本 - 它不起作用.

在此输入图像描述

有人知道,如何在gridview中设置图像而没有任何特殊的填充或空间来成功地与所有分辨率和设备一起工作?

layout android gridview padding stretch

10
推荐指数
1
解决办法
3万
查看次数

查找拉伸网页的元素?

我正在为http://digitaleditor.com/做一些工作,我遇到了一些令人困惑的事情.

网页底部有一个水平滚动条,但我一直无法弄清楚原因.使用谷歌Chrome的开发人员工具,我发现整个页面上只有3个项目超过960像素宽.前两个是htmlbody,第二个是#hpages,然而第二个只有970像素宽(html并且body每个宽1263像素).此外,有一个非常明显的CSS规则扩展#hpages到970像素:

#hpages ul {   width:970px; float:right; }
Run Code Online (Sandbox Code Playgroud)

我找不到拉伸这些htmlbody元素的规则.我尝试运行以下脚本来查看是否有任何我只是忽略的元素可能会拉伸页面:

javascript:widest=null;$("body *").each(function(){if(widest==null)widest=this;else if($(this).width()>$(widest).width())widest=this;});alert(widest.id);
Run Code Online (Sandbox Code Playgroud)

这返回#hpages,意味着身体中没有超过970像素宽的项目(即使身体被拉伸到1263像素).

没有影响body元素宽度或元素宽度的CSS规则html.

老实说,对于拉伸页面的内容感到遗憾,我不知道如何弄明白.在这一点上,我最后的办法是系统地从页面中删除项目,直到它被解决.我想知道是否有人知道更好的选择.

html css stretch width

10
推荐指数
1
解决办法
3814
查看次数

CGImage在CALayer中被拉伸

我有一个CGMmage对象的NSMutableArray.所有图像都有不同的尺寸(80x20像素,200x200像素,10x10像素等等)我试图在CALayer中设置动画,其大小为256x256像素.动画有效,但是我的CGImages被拉伸到CALayer的尺寸.我怎么能阻止我的CGImages缩放?

谢谢.

scale stretch calayer cgimage

9
推荐指数
1
解决办法
3052
查看次数