Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/179.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/13.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 在XML中设置相同的视图宽度或高度_Android_Xml_View_Size - Fatal编程技术网

Android 在XML中设置相同的视图宽度或高度

Android 在XML中设置相同的视图宽度或高度,android,xml,view,size,Android,Xml,View,Size,我开始学习android,我正在做一个简单的游戏。在这个游戏中,我需要两个宽度相同的滚动列表,所以我在两个视图中都将layout_weight参数设置为“1”。但当我运行程序时,滚动视图的大小不同。第二个问题是,我需要将EditText小部件设置为低,所以我对TableRows做了同样的事情,但最后我必须将权重设置为0.1,以达到所需的大小 如果有错误,我的英语很抱歉 <?xml version="1.0" encoding="utf-8"?> <TableLayout xml

我开始学习android,我正在做一个简单的游戏。在这个游戏中,我需要两个宽度相同的滚动列表,所以我在两个视图中都将layout_weight参数设置为“1”。但当我运行程序时,滚动视图的大小不同。第二个问题是,我需要将EditText小部件设置为低,所以我对TableRows做了同样的事情,但最后我必须将权重设置为0.1,以达到所需的大小

如果有错误,我的英语很抱歉

<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/widget28"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <TableRow
        android:id="@+id/widget29"
        android:layout_width="fill_parent"
        android:layout_weight="7"
        android:orientation="vertical" >

        <ScrollView
            android:id="@+id/widget34"
            android:layout_height="150px"
            android:layout_weight="1"
            android:background="#ffff00ff" >
        </ScrollView>

        <ScrollView
            android:id="@+id/widget35"
            android:layout_height="150px"
            android:layout_weight="1"
            android:background="#ff00ffff" >
        </ScrollView>
    </TableRow>

    <TableRow
        android:id="@+id/widget30"
        android:layout_width="fill_parent"
        android:layout_weight="0.1"
        android:orientation="vertical" >

        <EditText
            android:id="@+id/widget36"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:text="Not editable"
            android:textSize="18sp" >
        </EditText>
    </TableRow>

</TableLayout>


您的滚动视图位于同一表格行上。尝试将布局权重改为0.5。然后他们两个都应该得到半行。

问题解决了,我用LinearLayout替换了第二个TableRow,一切都开始正常工作。我不知道为什么,但两个表行以某种方式连接在一起,改变第二个表行的宽度改变了第一个表行的宽度

我将layout_weight更改为0.5,但界面中没有任何变化。另一件事是,我添加了可聚焦的文本视图,并将OnClickListener设置为它们,从而向EditText添加一个字母。当我运行程序并点击列表位置时,编辑文本的宽度和左滚动视图的宽度变化相等