Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/215.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 关于布局重量和边距_Android_Android Layout Weight - Fatal编程技术网

Android 关于布局重量和边距

Android 关于布局重量和边距,android,android-layout-weight,Android,Android Layout Weight,为什么当我设置按钮的属性layout\u margintart=“130dp”时,整个上部EditText会相应地移动 2-我计划将屏幕分为4个部分,总重量=9,第1、2、3、4部分应相应地具有2/9、2/9、4/9、1/9。如果我需要修改某些内容,请告诉我 XML: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com

为什么当我设置
按钮的属性
layout\u margintart=“130dp”
时,整个上部
EditText
会相应地移动

2-我计划将屏幕分为4个部分,总
重量=9
,第1、2、3、4部分应相应地具有2/9、2/9、4/9、1/9。如果我需要修改某些内容,请告诉我

XML

<LinearLayout
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:orientation="vertical"
android:weightSum="9"
tools:context="${relativePackage}.${activityClass}" >

<TableLayout 
    android:id="@+id/table_0"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="4">
    <TableRow 
        android:id="@+id/row0"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <TextView 
            android:id="@+id/tv_ip"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginStart="5dp"
            android:paddingTop="15dp"
            android:text="IP: "/>
        <EditText 
            android:id="@+id/et_ip"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:ems="12"/>
    </TableRow>

    <TableRow 
        android:id="@+id/row1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <TextView 
            android:id="@+id/tv_port"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginStart="5dp"
            android:paddingTop="15dp"
            android:text="Port: "/>
        <EditText 
            android:id="@+id/et_port"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:ems="12"/>
    </TableRow>

    <TableRow 
        android:id="@+id/row2"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <TextView 
            android:id="@+id/tv_clientid"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginStart="5dp"
            android:paddingTop="15dp"
            android:text="Client_ID"/>
        <EditText 
            android:id="@+id/et_clientid"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:ems="12"/>
    </TableRow>

    <TableRow 
        android:id="@+id/row3"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <TextView 
            android:id="@+id/tv_cleansession"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginStart="5dp"
            android:paddingTop="15dp"
            android:text="Clean Session"/>
        <CheckBox
            android:id="@+id/cbx_cleansession"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"/>
    </TableRow>

    <TableRow 
        android:id="@+id/row4"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <Button
            android:id="@+id/btn_conn"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginStart="130dp"
            android:gravity="center_vertical|center_horizontal"
            android:text="Connect"/>
        </TableRow>
</TableLayout>


1。从底部结束布局

</LenearLayout>
  • 最后一件事是,您只能使用EditText并给出提示。如果你想让它更好,那么你可以使用背景模板

  • 就这样。我希望您喜欢它

    但是现在,ip2textview2和它的edittext之间的空间/差距很大,即:ip
        <CheckBox
            android:id="@+id/cbx_cleansession"
            android:layout_width="match_parent"
            android:text="Clean Session"
            android:layout_height="wrap_content"/>
    </TableRow>`