标签: layout

对齐堆栈面板中的项目?

我想知道我是否可以在水平导向的StackPanel中有2个控件,以便正确的项目应该停靠在StackPanel的右侧.

我尝试了以下但它不起作用:

<StackPanel Orientation="Horizontal">
    <TextBlock>Left</TextBlock>
    <Button Width="30" HorizontalAlignment="Right">Right<Button>
</StackPanel>
Run Code Online (Sandbox Code Playgroud)

在上面的代码片段中,我希望Button停靠在StackPanel的右侧.

注意:我需要使用StackPanel,而不是Grid等.

wpf layout alignment wpf-controls stackpanel

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

CSS3 box-sizing:margin-box; 为什么不?

我们为什么不拥有box-sizing: margin-box;?通常当我们放入box-sizing: border-box;样式表时,我们真正意味着前者.


例:

假设我有一个2列页面布局.两列的宽度都是50%,但它们看起来有点难看,因为没有排水沟(中间有间隙); 下面是CSS:

.col2 {
    width: 50%;
    float: left;
}
Run Code Online (Sandbox Code Playgroud)


要应用排水沟,您可能会认为我们可以在2列中的第一列上设置右边距; 这样的事情:

.col2:first-child {
    margin-right: 24px;
}
Run Code Online (Sandbox Code Playgroud)

但这会使第二列换行到新行,因为以下情况属实:

50% + 50% + 24px > 100%
Run Code Online (Sandbox Code Playgroud)

box-sizing: margin-box;通过在元素的计算宽度中包含边距来解决此问题.如果不是更有用,我会发现这非常有用box-sizing: border-box;.

css layout w3c position css3

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

Android:如何以编程方式设置布局的大小

作为Android应用程序的一部分,我正在构建一个按钮集.这些按钮是嵌套的LinearLayouts集的一部分.使用权重我根据包含父LinearLayout的大小自动调整自身大小.该想法是,基于屏幕的像素数和密度,将包含布局的大小设置为多个像素; 并根据该更改让按钮设置自行调整大小.

那么问题是:如何调整布局大小.

我已经尝试了几种建议的技术,没有一种能够接近工作.以下是构建按钮集的XML的子集:

    <LinearLayout android:layout_height="104pt" android:id="@+id/numberPadLayout" android:orientation="horizontal" android:layout_width="104pt"
    android:background="#a0a0a0"
    android:layout_alignParentBottom="true" 
    android:layout_centerHorizontal="true"
>

    <LinearLayout android:layout_weight="2" android:layout_height="fill_parent" android:id="@+id/linearLayout1" android:orientation="vertical" android:layout_width="wrap_content">
        <Button android:text="1" android:id="@+id/button1" android:layout_weight="2" android:layout_width="fill_parent" android:layout_height="wrap_content"></Button>
        <Button android:text="4" android:id="@+id/button4" android:layout_weight="2" android:layout_width="fill_parent" android:layout_height="wrap_content"></Button>
        <Button android:text="7" android:id="@+id/button7" android:layout_weight="2" android:layout_width="fill_parent" android:layout_height="wrap_content"></Button>
        <Button android:text="-" android:id="@+id/buttonDash" android:layout_weight="2" android:layout_width="fill_parent" android:layout_height="wrap_content"></Button>
    </LinearLayout>
    <LinearLayout android:layout_weight="2" android:layout_height="fill_parent" android:id="@+id/linearLayout2" android:orientation="vertical" android:layout_width="wrap_content">
        <Button android:text="2" android:id="@+id/button2" android:layout_weight="2" android:layout_width="fill_parent" android:layout_height="wrap_content"></Button>
        <Button android:text="5" android:id="@+id/button5" android:layout_weight="2" android:layout_width="fill_parent" android:layout_height="wrap_content"></Button>
        <Button android:text="8" android:id="@+id/button8" android:layout_weight="2" android:layout_width="fill_parent" android:layout_height="wrap_content"></Button>
        <Button android:text="0" android:id="@+id/button0" android:layout_weight="2" android:layout_width="fill_parent" android:layout_height="wrap_content"></Button>
    </LinearLayout>

    <LinearLayout android:layout_weight="2" android:layout_height="fill_parent" android:id="@+id/linearLayout3" android:orientation="vertical" …
Run Code Online (Sandbox Code Playgroud)

layout android resize android-linearlayout

133
推荐指数
3
解决办法
25万
查看次数

100%宽度的Twitter Bootstrap 3模板

我是一个bootstrap新手,我有一个100%宽的模板,我想用bootstrap编码.第一列从左角开始,我有一张谷歌地图,最右边是延伸.我以为我可以用container-fluid课堂做这件事,但这似乎不再可用了.我不知道如何使用bootstrap 3实现该布局.我正在使用来自themeforest的几何PSD模板,如果你想看到布局,请点击这里的链接:http://themeforest.net/item/geometry-design-for- 地理位置-社会- networkr/4752268

html css layout twitter-bootstrap twitter-bootstrap-3

133
推荐指数
5
解决办法
32万
查看次数

如何在右侧显示android复选框?

默认情况下,android复选框显示右侧的文本和左侧的复选框
我想在右侧显示复选框,左侧显示文本

我怎么做到这一点?

checkbox layout android

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

在ScrollView中查看并不占用所有位置

我在ScrollView中有一个RelativeLayout.我的RelativeLayout有android:layout_height="match_parent"但是视图不占用整个大小,它就像一个wrap_content.

有没有办法让真正的fill_parent/match_parent行为?

我的布局:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">

    <ImageView
    android:id="@+id/top"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:scaleType="fitXY"
    android:src="@drawable/top" />

    <ImageView
    android:id="@+id/header"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/top"
    android:scaleType="fitXY"
    android:src="@drawable/headerbig" />

    <ImageView
    android:id="@+id/logo"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBottom="@+id/header"
    android:layout_centerHorizontal="true"
    android:layout_marginBottom="3dp"
    android:src="@drawable/logo" />

    <ScrollView
    android:layout_width="fill_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/bottom"
    android:layout_below="@+id/logo"
    android:background="@drawable/background" >

        <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">

             <ImageView
            android:id="@+id/dashboard01"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_above="@+id/dashboard02"
            android:layout_centerHorizontal="true"
            android:layout_marginBottom="30dp"
            android:src="@drawable/dashboard01"
            android:visibility="visible" />

            <ImageView
            android:id="@+id/dashboard02"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:layout_alignParentRight="true"
            android:layout_marginRight="10dp"
            android:src="@drawable/dashboard02" />

             <ImageView
            android:id="@+id/dashboard03"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/dashboard02"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="40dp"
            android:src="@drawable/dashboard03"
            android:visibility="visible" />
         </RelativeLayout>
    </ScrollView>

    <ImageView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/logo"
    android:layout_centerHorizontal="true" …
Run Code Online (Sandbox Code Playgroud)

layout android scrollview

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

理解convertRect:toView:,convertRect:FromView:,convertPoint:toView:和convertPoint:fromView:methods

我试图了解这些方法的功能.你能给我一个简单的用例来理解他们的语义吗?

从文档中,例如,convertPoint:fromView:方法描述如下:

将点从给定视图的坐标系转换为接收器的坐标系.

什么是坐标系是什么意思?接收器怎么样?

例如,使用convertPoint:fromView是否有意义:如下所示?

CGPoint p = [view1 convertPoint:view1.center fromView:view1];
Run Code Online (Sandbox Code Playgroud)

使用NSLog实用程序,我已经验证了p值与view1的中心重合.

先感谢您.

编辑:对于那些感兴趣的人,我创建了一个简单的代码片段来理解这些方法.

UIView* view1 = [[UIView alloc] initWithFrame:CGRectMake(100, 100, 150, 200)];
view1.backgroundColor = [UIColor redColor];

NSLog(@"view1 frame: %@", NSStringFromCGRect(view1.frame));        
NSLog(@"view1 center: %@", NSStringFromCGPoint(view1.center));   

CGPoint originInWindowCoordinates = [self.window convertPoint:view1.bounds.origin fromView:view1];        
NSLog(@"convertPoint:fromView: %@", NSStringFromCGPoint(originInWindowCoordinates));

CGPoint originInView1Coordinates = [self.window convertPoint:view1.frame.origin toView:view1];        
NSLog(@"convertPoint:toView: %@", NSStringFromCGPoint(originInView1Coordinates));
Run Code Online (Sandbox Code Playgroud)

在这两种情况下,self.window都是接收者.但是有区别.在第一种情况下,convertPoint参数以view1坐标表示.输出如下:

convertPoint:fromView:{100,100}

而在第二个中,convertPoint以superview(self.window)坐标表示.输出如下:

convertPoint:toView:{0,0}

layout uiview ios

127
推荐指数
5
解决办法
7万
查看次数

在Android中以编程方式删除背景可绘制

我想以编程方式删除背景drawable(@ drawable/bg).有没有办法做到这一点?

目前,我的布局中有以下XML:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    android:id="@+id/widget29"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:background="@drawable/bg">

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

layout android background

124
推荐指数
4
解决办法
11万
查看次数

EditText,inputType值(xml)

我在哪里可以找到InputType可以拥有的值?

我知道http://developer.android.com/reference/android/text/InputType.html,但是布局xml文件中的值应如何?

layout android android-edittext android-inputtype

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

如何在引导流体布局中底部对齐网格元素

我使用Twitter的bootstrap进行流畅的布局,其中我有一行有两列.第一列有很多内容,我想通常填写范围.第二列只有一个按钮和一些文本,我想在第一列中相对于单元格进行底部对齐.

这就是我所拥有的:

-row-fluid-------------------------------------
+-span6----------+ +-span6----------+
|                | |short content   |
| content        | +----------------+
| that           | 
| is tall        |    
|                |
+----------------+
-----------------------------------------------
Run Code Online (Sandbox Code Playgroud)

这就是我想要的:

-row-fluid-------------------------------------
+-span6----------+
|                |
| content        |
| that           | 
| is tall        | +-span6----------+    
|                | |short content   |
+----------------+ +----------------+
-----------------------------------------------
Run Code Online (Sandbox Code Playgroud)

我已经看到使第一个跨度成为绝对高度的解决方案,并相对于它定位第二个跨度,但是我不需要指定我的div的绝对高度的解决方案将是首选.我也愿意彻底重新思考如何达到同样的效果.我没有嫁给这种脚手架的使用,它似乎对我来说最有意义.

这种布局作为小提琴:

http://jsfiddle.net/ryansturmer/A7buv/3/

html css layout twitter-bootstrap

120
推荐指数
7
解决办法
18万
查看次数