XML Android布局问题

用户名

所以我在使用一些XML布局编码时遇到了问题...我应该复制该图像

http://s28.postimg.org/n257m4dil/Untitled.png

但是到目前为止,我似乎只能做到这一点,即使我确实使用android:gravity =“ right”将右移到其容器内,结帐按钮也不会停留在右边...:/

http://s29.postimg.org/bqzspid13/pic3.png

这是我到目前为止的代码:

<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:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".CartActivity" >

<LinearLayout
    android:id="@+id/linearLayout1"
    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:textColor="#FFFFFF"
        android:text="Shopping Cart"
        android:background="@android:color/holo_blue_dark" />

    <LinearLayout
        android:id="@+id/linearLayout2"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:background="@android:color/holo_blue_light"
         >

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

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textColor="#800000"
            android:text="£???" />

        <Button
            android:id="@+id/checkout"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:gravity="right"
            android:text="Checkout" >
        </Button>
    </LinearLayout>
</LinearLayout>

安卓

android:weightSum="3"你的内心

用这三个元素进行布局,然后,

android:layout_weight="1" 到每个视图

这将使视图占据可用空间的1/3

<LinearLayout
    android:id="@+id/linearLayout2"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:background="@android:color/holo_blue_light"
    android:weightSum="3"
     >

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Subtotal:" 
        android:layout_weight="1"/>

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textColor="#800000"
        android:text="£???"
        android:layout_weight="1" />

    <Button
        android:id="@+id/checkout"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:gravity="right"
        android:text="Checkout" 
        android:layout_weight="1">
    </Button>
</LinearLayout>

EDIT fill_parent不建议使用match_parent

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

XML Android布局问题

来自分类Dev

Android XML布局中的分频器问题

来自分类Dev

XML布局有一些问题(Android开发)

来自分类Dev

XML Android定位布局

来自分类Dev

Android-XML布局

来自分类Dev

Android XML 布局设计

来自分类Dev

不同屏幕分辨率的矢量xml可绘制文件的Android应用布局问题

来自分类Dev

不同布局文件夹中的相同xml文件名问题(android)

来自分类Dev

XML布局中的Android GLSurfaceView

来自分类Dev

Android底表布局XML

来自分类Dev

xml android准则约束布局

来自分类Dev

xml中的Android框架布局

来自分类Dev

XML布局中的Android GLSurfaceView

来自分类Dev

android app:布局xml文件

来自分类Dev

android:xml布局中的OnDraw

来自分类Dev

XML android布局隐藏图标

来自分类Dev

Android布局XML旋转方向

来自分类Dev

Android Studio:InvalidVirtualFileAccessException尝试呈现XML布局

来自分类Dev

带有图像按钮的Android XML布局

来自分类Dev

Android XML布局中条件语句的语法

来自分类Dev

从Android中的xml布局获取节点

来自分类Dev

将Xml布局到我的android应用

来自分类Dev

Android:Row.xml的相对布局

来自分类Dev

Eclipse抱怨android布局xml文件

来自分类Dev

使用xml的android布局中的全角按钮

来自分类Dev

Android XML与代码表布局差异

来自分类Dev

Android图像叠加层中的XML布局

来自分类Dev

Android XML布局声明(纵向,横向模式)

来自分类Dev

带有图像按钮的Android XML布局