【问题标题】:Managing width in xml在 xml 中管理宽度
【发布时间】:2017-03-21 06:54:35
【问题描述】:

我正在 android studio 中处理我的 xml 文件。

我想让旁边有箭头的“surnameEditText”和“nameEditText”Picture 与位于它们下方的输入表单具有相同的宽度。

如何做到这一点?这是我的代码。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_register"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/pozadina"
    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="com.xyz.ui.RegisterActivity">

    <LinearLayout
        android:id="@+id/linearLayout2"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/signUpTextView"
        android:layout_centerHorizontal="true"
        android:orientation="vertical">

        <TextView
            android:id="@+id/signUpTextView"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:layout_centerHorizontal="true"
            android:layout_marginBottom="15dp"
            android:text="Sign up"
            android:textAlignment="center"
            android:textColor="#ffffffff"
            android:textSize="30sp" />

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="horizontal">

            <EditText
                android:id="@+id/nameEditText"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_margin="10dp"
                android:layout_weight="1"
                android:backgroundTint="#ffffffff"
                android:ems="10"
                android:hint="Name"
                android:inputType="textPersonName"
                android:textColorHint="#95ffffff" />

            <EditText
                android:id="@+id/surnameEditText"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_margin="10dp"
                android:layout_weight="1"
                android:backgroundTint="#ffffffff"
                android:ems="10"
                android:hint="Surname"
                android:inputType="textPersonName"
                android:textColorHint="#95ffffff" />

        </LinearLayout>


    </LinearLayout>



</RelativeLayout>

【问题讨论】:

  • 你给其他领域多少利润?为 Name 和 Surname 设置相同的边距。现在是 10dp
  • 这是我在这两个下方的输入表单代码。

标签: android xml width


【解决方案1】:

顶部视图只有margin 10dp,其余视图有marginLeft 16dp。将顶视图的margin 也更改为16dp

【讨论】:

    猜你喜欢
    • 2011-11-30
    • 1970-01-01
    • 2019-08-21
    • 2010-12-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-04-25
    • 1970-01-01
    相关资源
    最近更新 更多