标签: padding

填充不适用于ImageButton

在我正在开发的应用程序中,我有几个ImageButtons.每个ImageButton都有一个drawable形式的背景和内容.现在drawable在ImageButton的范围内处于最大尺寸,但我希望它缩小,所以我需要添加一些填充.问题在于,当我尝试这样做时,它没有任何效果.我的XML对于每个ImageButton如下:

<ImageButton
    android:id="@+id/button_zero"
    android:layout_width="0dip"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:padding="10dip"
    android:src="@drawable/button_zero"
    android:background="@drawable/button_background" />
Run Code Online (Sandbox Code Playgroud)

任何想法为什么填充不做任何事情?

完整的XML代码:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#222222"
    tools:context=".Main" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical" >

        <!-- Row One -->
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal" >
            <ImageButton
                android:id="@+id/button_zero"
                android:layout_width="0dip"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:padding="10dip"
                android:src="@drawable/button_zero"
                android:background="@drawable/button_front" />
            <ImageButton
                android:id="@+id/button_one"
                android:layout_width="0dip"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:padding="10dip"
                android:src="@drawable/button_one"
                android:background="@drawable/button_front" />
            <ImageButton
                android:id="@+id/button_two"
                android:layout_width="0dip"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:padding="10dip"
                android:src="@drawable/button_two"
                android:background="@drawable/button_front" />
            <ImageButton
                android:id="@+id/button_three"
                android:layout_width="0dip"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:padding="10dip"
                android:src="@drawable/button_three"
                android:background="@drawable/button_front" />
            <ImageButton
                android:id="@+id/button_four"
                android:layout_width="0dip"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:padding="10dip"
                android:src="@drawable/button_four"
                android:background="@drawable/button_front" />
        </LinearLayout> …
Run Code Online (Sandbox Code Playgroud)

android padding imagebutton

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

43
推荐指数
4
解决办法
6万
查看次数

div的中心文字?

我有一个div 30px高和500px宽.这div可以包含两行文本,一行在另一行之下,并相应地设置样式(填充).但有时它只包含一行,我希望它居中.这可能吗?

css padding spacing

42
推荐指数
7
解决办法
14万
查看次数

结构包装是否具有确定性?

例如,假设我有两个等效的结构ab不同的项目:

typedef struct _a
{
    int a;
    double b;
    char c;
} a;

typedef struct _b
{
    int d;
    double e;
    char f;
} b;
Run Code Online (Sandbox Code Playgroud)

假设我没有使用任何类似的指令,#pragma pack并且这些结构在同一架构上的相同编译器上编译,它们在变量之间是否具有相同的填充?

c padding

42
推荐指数
5
解决办法
3731
查看次数

填充C中的结构

这是一个面试问题.直到现在,我曾经认为这些问题纯粹依赖于编译器,不应该担心我,但现在,我对它很好奇.

假设您有两种结构:

struct A {  
  int* a;  
  char b;  
 }  
Run Code Online (Sandbox Code Playgroud)

而且,

struct B {  
  char a;  
  int* b;  
}  
Run Code Online (Sandbox Code Playgroud)

那么你更喜欢哪一个?为什么?我的回答是这样的(虽然我有点在黑暗中拍摄)第一个结构应该是首选的,因为编译器为字大小的一些倍数(这是指针的大小 - 在32上的4个字节)分配结构的空间位机和64位的8字节).因此,对于这两种结构,编译器将分配8个字节(假设它是32位机器).但是,在第一种情况下,填充将在所有变量之后(即在a和b之后)完成.因此,即使有一些机会,b得到一些溢出的值并破坏我的下一个填充字节,但我的a仍然是安全的.

他似乎并不高兴,并要求第一个结构在第二个结构上的一个缺点.我没有太多话要说.:d

请帮我解答.

c structure padding

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

Android View setPadding()vs setPaddingRelative()

基于Android 文档并没有给出太多解释,setPadding()vs 之间有什么区别setPaddingRelative()

android padding android-view

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

在WebView Android中删除不需要的空格

我已经开始使用WebView开发应用程序了.实际上我正在使用Webview加载图像(我喜欢使用该类的内置缩放控件).我可以成功加载图像,但我可以看到一些恼人的白色空间.我找不到删除它的方法.我的图片尺寸为750*1000.我在下面附上了我的代码.

webview.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" >
    <WebView
        android:id="@+id/webView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

ImageViewer.java

package com.android.test;

import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;

public class ImageViewer extends Activity {

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.webview);

        String loadUrl = "file:///android_res/drawable/splash_001.jpg";

        WebView image = (WebView) findViewById(R.id.webView);
        image.clearView();
        image.clearCache(true);
        image.getSettings().setBuiltInZoomControls(true);
        image.getSettings().setSupportZoom(true);
        image.getSettings().setLoadWithOverviewMode(true);
        image.getSettings().setUseWideViewPort(true);
        image.loadUrl(loadUrl);
    }

}
Run Code Online (Sandbox Code Playgroud)

android space image padding android-webview

38
推荐指数
5
解决办法
4万
查看次数

如何在WebView周围添加填充

我的布局文件定义了一个WebView,下面有一些固定的高度按钮.

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

  <WebView
    android:id="@+id/webview"
    android:layout_width="fill_parent"
    android:layout_height="0dp"
    android:layout_weight="1.0"/>

  <LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="60dp"
    android:padding="8dp">

    <Button
      android:text="Decline"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_weight="1.0">
    </Button>

    <Button
      android:text="Accept"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_weight="1.0">
    </Button>

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

我正在尝试在WebView周围添加填充,就像文本一直运行到UI的边缘一样.

我尝试添加android:padding="8dp"到WebView,但没有添加填充.我也尝试过paddingLeft和paddingRight,但它们也没有用.

网页视图 API文档确认它查看,支持继承的android:填充属性,所以我很惊讶这没有奏效.

有人知道这是一个已知的问题,还是我的布局XML的一些互动,我不理解?

仅供参考,我的解决方法是在WebView周围添加额外的LinearLayout,并将填充添加到其中:

  <LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="0dp"
    android:layout_weight="1.0"
    android:padding="8dp">

    <WebView
      android:id="@+id/webview"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"/>

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

android padding android-layout android-webview

38
推荐指数
4
解决办法
2万
查看次数

css - 摆脱跨度之间的空间

我正在尝试使用html模拟标签栏

我想根据文本长度(即没有固定宽度)设置每个标签的宽度,并在超出屏幕宽度时自动换行

我几乎实现了它

<html>
<head>

<style type="text/css">
    #myTabs .tab {
    float: left;
    }

    #myTabs .tab_middle {
        margin: 0;
        padding: 0;
        border: none;
    background-image:url('images/tabs/tab_middle.png');
    }

    #myTabs .tab_left {
        margin: 0;
        padding: 0;
        border: none;
        background-image:url('images/tabs/tab_left.png');
    }

    #myTabs .tab_right {
        margin: 0;
        padding: 0;
        border: none;
    background-image:url('images/tabs/tab_right.png');
    }

</style>

</head>

<body>

<div id="myTabs">
  <div class='tab'>
        <span class='tab_left'>&nbsp;</span>
        <span class='tab_middle'>very very looong</span>
        <span class='tab_right'>&nbsp;</span>
    </div>
  <div class='tab'>
        <span class='tab_left'>&nbsp;</span>
        <span class='tab_middle'>another loooong tab</span>
        <span class='tab_right'>&nbsp;</span>
    </div>
    <div style='clear:both'></div>
</div>

</body>
</html>
Run Code Online (Sandbox Code Playgroud)

但是,在开启标签图像和结束标签图像之间有一个非常烦人的空间......

你可以看到我尝试过填充,间距和边框,没有运气...... …

html css padding

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

将"填充"添加到UITextView

正如标题所说我试图向UITextView添加类似填充的行为.在我的导航控制器中按下视图时会生成textview,并出现以下代码:

 self.textView.layer.cornerRadius = 7;
 //pretty stuff is pretty

 NSString *description = appDelegate.productInDisplay.description;
 [self.textView setText:description];
 //pretty stuff has content now


 CGRect frame = textView.frame;
 frame.size.height = textView.contentSize.height;
 textView.frame = frame;
 //set the UITextView to the size of it's containing text.

 self.textView.editable = NO;

  self.theScrollView.contentSize = CGSizeMake(320, 250 + textView.frame.size.height);
  //set the parent scrollView's height to fit some other elements with fixed size (250)
  //and the pre-mentioned UITextView
Run Code Online (Sandbox Code Playgroud)

所以,它一切正常,没关系,但我想在UITextView的所有4个方面添加一些填充,我已经无法用3小时的谷歌搜索看起来相当容易的东西.有什么建议?

padding uitextview ios

36
推荐指数
6
解决办法
4万
查看次数