简体   繁体   English

我的.xml文件布局在模拟中无法正确显示

[英]My .xml files layout is not showing properly in simulation

In this case, my xml file shows a certain layout while at runtime another one is generated. 在这种情况下,我的xml文件显示了某种布局,而在运行时生成了另一种布局。 I am incredibly confused as to why the layout shown at runtime is completely different from the one given. 我对为什么运行时显示的布局与给定的布局完全不同感到困惑。 here is the code for the xml file 这是xml文件的代码

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

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical" >


        <EditText
            android:id="@+id/username"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:ems="10" >

            <requestFocus />
        </EditText>
    </LinearLayout>

    <Button
        android:id="@+id/signUp"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Sign up!" />
</LinearLayout>

This displays Insert name here on both a label and button. 这将在标签和按钮上都在此处显示插入名称。 The button is correctly bound and pressing it does do something, however I cannot type in the textfield at runtime. 该按钮已正确绑定,按下它会执行某些操作,但是我无法在运行时在文本字段中键入。

This one looks fine. 这个看起来不错。 Double check if you are changing any property with your java code. 仔细检查您是否正在使用Java代码更改任何属性。

Try to use this one instead. 尝试改用这个。 I have removed the useless LinearLayout and try to make the EditText clickable. 我已经删除了无用的LinearLayout,并尝试使EditText可单击。

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

    <EditText
        android:id="@+id/username"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:clickable="true"
        android:ems="10" >

        <requestFocus />
    </EditText>

    <Button
        android:id="@+id/signUp"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="Sign up!" />
</LinearLayout>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM