我正在尝试使用iTextSharp为文档添加表格.这是一个例子:
Document document = new Document(PageSize.LETTER,72, 72, 72, 72);
PdfWriter writer = PdfWriter.GetInstance(document, new FileStream("C:\\test.pdf", FileMode.Create));
document.Open();
Table table = new Table ( 2, 1 );
table.Width = document.RightMargin - document.LeftMargin;
// Cell placeholder
Cell cell = new Cell ( new Paragraph ( "Some Text" ) );
table.AddCell ( cell );
cell = new Cell ( new Paragraph ( "More Text" ) );
table.AddCell ( cell );
document.Add ( table );
document.Close ( );
Run Code Online (Sandbox Code Playgroud)
我正在设置表格的宽度,以便它应该扩展页面的边距.但是当创建pdf时,表格只占边距之间的80%.我在这里做错了吗?
我使用matplotlib 0.99.
我无法改变边框的宽度,subplot我该怎么办呢?
代码如下:
fig = plt.figure(figsize = (4.1, 2.2))
ax = fig.add_subplot(111)
ax.patch.set_ linewidth(0.1)
ax.get_frame().set_linewidth(0.1)
Run Code Online (Sandbox Code Playgroud)
最后两行不起作用,但以下工作正常:
legend.get_frame().set_ linewidth(0.1)
Run Code Online (Sandbox Code Playgroud) 在尝试计算隐藏元素的宽度时,我发现jquery.width()为该元素的宽度返回0.
我发现使用jquery.css('width')会通过使用声明的样式宽度返回正确的宽度(即使该值与初始样式表不同).问题是css('width')方法返回一个字符串,通常是"100px"方式.我的问题解决了:如何从"100px"字符串中检索数字?有一个简单的方法吗?
所以我在android中有一个TextView,它具有整个屏幕长度的宽度和一个dip 5的填充.我如何计算出适合屏幕上一行的字符数?我想换句话说,我正在尝试获取textview的列数?
我考虑了手工计算取决于文本大小和宽度,但是1)不知道相关性和2)由于以倾角为单位的填充,不同的屏幕将使用不同数量的实际像素来填充.
总体问题:我正在尝试使用它来解决:如果给出一个字符串,我怎样才能手动编辑为字符串,这样当textview逐字符打印字符串时,我将知道何时开始一个不适合一个字符的单词下一行.注意:我知道textview会自动放入不适合下一行的单词,但是,由于我是逐个字符打印,比如输入动画,textview不知道这个单词在打印出来之前是不适合的溢出的那个词的字符.
一直在寻找这个......
谢谢!
添加解决方案
一种可能的方案:
public String measure2 (TextView t, String s) {
String u = "";
int start = 0;
int end = 1;
int space = 0;
boolean ellipsized = false;
float fwidth = t.getMeasuredWidth();
for(;;) {
//t.setText(s.substring(start, end));
float twidth = t.getPaint().measureText(s.substring(start, end));
if (twidth < fwidth){
if (end < s.length())
end++;
else {
if (!ellipsized)
return s;
return u + s.subSequence(start, end);
}
}
else {
ellipsized = true;
space = (u + …Run Code Online (Sandbox Code Playgroud) 给定一个<textarea>固定的width,我希望它的"有效宽度"是常数(in px)."活动宽度"是指文本出现的区域.
当没有出现垂直滚动条时,"活动宽度"等于width.但是,当出现垂直滚动条时,"活动宽度"变得小于width(我猜测精确地小于滚动条的宽度).
我想确定是否出现垂直滚动条,如果是,则增加<textarea>滚动条宽度的宽度.如何识别滚动条的宽度?
有更好的方法吗?
(我对Firefox感兴趣,如果它让生活变得更轻松.)
如果我有一个<div>相对宽度(例如宽度:50%),是否有一种简单的方法可以使它具有与高度相同的宽度而无需借助JavaScript?
我有以下html结构: -
<div>
<span>
<a href="wherever">Wherever</a>
</span>
</div>
Run Code Online (Sandbox Code Playgroud)
如果我希望跨度覆盖div的整个宽度,我该如何在chrome中做到这一点?
我尝试用css
span{
background:#FFF;
width:100%;
}
Run Code Online (Sandbox Code Playgroud)
它适用于firefox,但不适用于chrome.
我正在关注这篇文章https://css-tricks.com/almanac/properties/w/width/,试图了解这个规则的工作原理.
我有这个例子:
*{margin:0; padding:0}
.box{
background: lightgreen;
margin: 0 auto;
width: -webkit-fit-content;
width: -moz-fit-content;
width: fit-content;
}Run Code Online (Sandbox Code Playgroud)
<div class="box">
<img src="https://tyrannyoftradition.files.wordpress.com/2012/05/cutest-kitten-hat-ever-13727-1238540322-17.jpg" alt="" />
<figure>Yes, put some text here that is wider than the image above to try some new rules</figure>
</div>Run Code Online (Sandbox Code Playgroud)
文章说,fit-content可以用来将未知宽度的div居中 margin: x auto;
但是如果你在这个例子中更改了max-content的fit-content,那么无论如何它都会起作用,并且它们似乎总是以相同的方式运行.
有谁知道这两条规则之间有什么区别,我应该在哪些情况下使用其中一条规则?
我正在创造RecycleView一些物品.所以我需要得到一行的宽度和高度RecycleView
我在这里创造RecycleView:
RecyclerView rvSmetki = (RecyclerView) findViewById(R.id.rvArtikli);
rvSmetki.setLayoutManager(new GridLayoutManager(this, 3););
rvSmetki.setAdapter(new ArtikliAdapter(this));
// Here I want to get width and height....
Run Code Online (Sandbox Code Playgroud)
这是我的ArtikliAdapter:
public class ArtikliAdapter extends RecyclerView.Adapter<ArtikliAdapter.ViewHolder> {
private static Context context;
private LayoutInflater inflater;
private ArrayList<Artikl> artikliList;
public ArtikliAdapter(Context context) {
this.context = context;
inflater = LayoutInflater.from(context);
artikliList = LogInActivity.getArtiklList();
}
@Override
public ArtikliAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View row = inflater.inflate(R.layout.artikli_row, parent, false);
return new ArtikliAdapter.ViewHolder(row);
}
@Override
public void onBindViewHolder(ArtikliAdapter.ViewHolder holder, …Run Code Online (Sandbox Code Playgroud) 我想知道是否有一种方法可以在代码中将ColumnDefinition Width设置为*,就像在xaml文件中一样.当尝试在代码中设置GridLength时,只有Auto有一个选项.
<ColumnDefinition Width="*"/>
Run Code Online (Sandbox Code Playgroud)
谢谢你的帮助.