标签: padding

以编程方式在视图上添加填充

我正在开发Android v2.2应用程序.

我有一个片段.

onCreateView(...)我的片段类的回调中,我将布局扩展到片段,如下所示:

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.login, null);

    return view;
}
Run Code Online (Sandbox Code Playgroud)

上面膨胀的布局文件是(login.xml):

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" 
 >

    <TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="Username" />


    <TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="Username" />

</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

我想设置一个paddingTop上面的<LinearLayout>元素,我想在Java代码中执行它而不是在xml中执行它.

如何设置paddingTop<LinearLayout>我的片段Java类代码?

android padding android-widget android-emulator android-layout

221
推荐指数
9
解决办法
23万
查看次数

如何防止填充属性在CSS中更改宽度或高度?

我用DIVs 创建一个网站.除非我创建DIV,否则一切正常.我像这样创建它们(例子):

newdiv {
    width: 200px;
    height: 60px;
    padding-left: 20px;
    text-align: left;
}
Run Code Online (Sandbox Code Playgroud)

当我添加padding-left属性时,DIV更改的宽度为220px,我希望它保持在200px.

假设我创建另一个DIV名称anotherdiv完全相同newdiv,并将其放入其中newdivnewdiv没有填充并且anotherdiv具有padding-left: 20px.我得到同样的东西,newdiv宽度将是220px.

我该如何解决这个问题?

html css padding css3

216
推荐指数
6
解决办法
17万
查看次数

结构填料和包装

考虑:

struct mystruct_A
{
   char a;
   int b;
   char c;
} x;

struct mystruct_B
{
   int b;
   char a;
} y;
Run Code Online (Sandbox Code Playgroud)

结构的尺寸分别为12和8.

这些结构是填充还是包装?

什么时候进行填充或包装?

c struct structure packing padding

189
推荐指数
6
解决办法
25万
查看次数

Android:TextView:删除顶部和底部的间距和填充

当我在文本中有a TextView\n,在右边我有两个singleLine TextViews,一个在另一个之下,两者之间没有间距.我为所有三个人设置了以下内容TextView.

android:lineSpacingMultiplier="1" 
android:lineSpacingExtra="0pt" 
android:paddingTop="0pt" 
android:paddingBottom="0pt"
Run Code Online (Sandbox Code Playgroud)

左边的第一行TextView与右上角完美排列TextView.

左边TextView的第二行略高于右下角的第二行TextView.

似乎在TextViews 的顶部和底部有某种隐藏的填充.我怎么能删除它?

android padding spacing textview

181
推荐指数
12
解决办法
14万
查看次数

绝对定位忽略父级的填充

你如何使绝对定位元素尊重其父元素的填充?我希望内部div在其父级的宽度上伸展,并且位于该父级的底部,基本上是一个页脚.但孩子必须尊重父母的填充,而不是那样做.孩子被压在父母的边缘.

所以我想要这个:

在此输入图像描述

但是我得到了这个:

在此输入图像描述

<html>
  <body>
    <div style="background-color: blue; padding: 10px; position: relative; height: 100px;">
      <div style="background-color: gray; position: absolute; left: 0px; right: 0px; bottom: 0px;">css sux</div>
    </div>
  </body>
</html>
Run Code Online (Sandbox Code Playgroud)

我可以通过内部div的边缘来实现它,但我宁愿不必添加它.

css css-position padding

159
推荐指数
5
解决办法
9万
查看次数

添加空间/填充到UILabel

我有一个UILabel我想在顶部和底部添加空间的地方.在约束中使用最小高度我将其修改为:

在此输入图像描述

编辑:要做到这一点,我用过:

  override func drawTextInRect(rect: CGRect) {
        var insets: UIEdgeInsets = UIEdgeInsets(top: 0.0, left: 10.0, bottom: 0.0, right: 10.0)
        super.drawTextInRect(UIEdgeInsetsInsetRect(rect, insets))

    } 
Run Code Online (Sandbox Code Playgroud)

但我要找到一种不同的方法,因为如果我写两行以上的问题是相同的:

在此输入图像描述

padding uilabel ios

156
推荐指数
19
解决办法
20万
查看次数

使用PyCrypto AES 256加密和解密

我正在尝试使用PyCrypto构建两个函数,它们接受两个参数:消息和密钥,然后加密/解密消息.

我在网上发现了几个链接来帮助我,但每个链接都有缺陷:

在codekoala上的这个使用os.urandom,PyCrypto不鼓励这样做.

而且,我给函数的关键不能保证具有预期的确切长度.我该怎么做才能实现这一目标?

此外,还有几种模式,建议使用哪种模式?我不知道该用什么:/

最后,究竟是什么?我可以为加密和解密提供不同的IV,还是会以不同的结果返回?

这是我到目前为止所做的:

from Crypto import Random
from Crypto.Cipher import AES
import base64

BLOCK_SIZE=32

def encrypt(message, passphrase):
    # passphrase MUST be 16, 24 or 32 bytes long, how can I do that ?
    IV = Random.new().read(BLOCK_SIZE)
    aes = AES.new(passphrase, AES.MODE_CFB, IV)
    return base64.b64encode(aes.encrypt(message))

def decrypt(encrypted, passphrase):
    IV = Random.new().read(BLOCK_SIZE)
    aes = AES.new(passphrase, AES.MODE_CFB, IV)
    return aes.decrypt(base64.b64decode(encrypted))
Run Code Online (Sandbox Code Playgroud)

python encryption padding pycrypto initialization-vector

153
推荐指数
9
解决办法
35万
查看次数

向字符串添加零填充

如何在字符串中添加"0"填充,以便我的字符串长度始终为4?

If input "1", 3 padding is added = 0001
If input "25", 2 padding is added = 0025
If input "301", 1 padding is added = 0301
If input "4501", 0 padding is added = 4501
Run Code Online (Sandbox Code Playgroud)

c# string padding

148
推荐指数
5
解决办法
15万
查看次数

Base64长度计算?

看完base64 维基 ...

我想弄清楚公式是如何工作的:

给定长度为的字符串n,base64长度为在此输入图像描述

这是: 4*Math.Ceiling(((double)s.Length/3)))

我已经知道base64长度必须是%4==0让解码器知道原始文本长度是多少.

序列的最大填充数可以是===.

wiki:每个输入字节的输出字节数约为4/3(开销为33%)

题:

上述信息如何与输出长度相符 在此输入图像描述

string base64 formula padding

142
推荐指数
8
解决办法
15万
查看次数

WPF:具有列/行边距/填充的网格?

是否可以轻松地为WPF网格中的行或列指定边距和/或填充?

我当然可以添加额外的列来解决问题,但这似乎是填充/边距的工作(它将提供简单的XAML).有人从标准网格派生出来添加此功能吗?

wpf grid margin padding

125
推荐指数
6
解决办法
15万
查看次数