[英]why does my editText doesn't presents the right output in android?
[英]android - Why my editText doesn't show?
大家好,这里需要帮助。
我不明白为什么我的editText没有出现。 我很困惑的是,我可以在我的日食大纲中看到editText。
这是我的代码:
activity_main.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="horizontal" >
<Button
android:id="@+id/buttonTESTER1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/btnTester1_text"
/>
<EditText
android:id="@+id/editTextTESTER1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="@string/editTextHINT1"
android:inputType="text"
/>
</LinearLayout>
strings.xml
<resources>
<string name="app_name">Android Tutorial</string>
<string name="hello_world">Hello world!</string>
<string name="menu_settings">Settings</string>
<string name="title_activity_main">MainActivity</string>
<string name="btnTester1_text">BUTTON TESTER</string>
<string name="editTextTester1_text">BUTTON TESTER</string>
<string name="editTextHINT1">Test</string>
</resources>
我是一个绝对的菜鸟,所以请耐心等待。 请指出我做错了什么。
因为你已经在你的按钮中传递了android:layout_width="fill_parent"
并且占据了你屏幕的整个宽度。要么将LinearLayout
的android:orientation="horizontal"
属性更改为vertical,要么将android:layout_width="fill_parent"
更改为wrap_content
。
尝试这个。
将LinearLayout的方向更改为“垂直”。 然后它们将垂直对齐。 发生这种情况是因为您在Button中设置了layout_width =“fill_parent”,它将填充整个父级,因此不会显示您的EditText框。
让我想想你到底想做什么?
<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" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:id="@+id/buttonTESTER1"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:text="@string/btnTester1_text"
/>
<EditText
android:id="@+id/editTextTESTER1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="@string/editTextHINT1"
android:inputType="text"
/>
</LinearLayout>
</LinearLayout>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.