【发布时间】:2019-04-18 03:55:18
【问题描述】:
这是activity_main.xml:
<?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:layout_width="match_parent"
android:layout_height="match_parent"
>
<TextView
android:id="@+id/label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Text:"
/>
<EditText
android:layout_toRightOf="@id/label"
android:layout_toEndOf="@id/label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="text"
android:hint="type ur text here"
android:layout_alignBaseline="@id/label"
/>
</RelativeLayout>
在设计中,在 Android Studio 上,TextView 和 EditText 都可以看到,但编译后只有 TextView 是可见的。
为什么?
截图
设计:
Apk:
谢谢
样式.xml:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar">
<!-- Customize your theme here. -->
</style>
</resources>
【问题讨论】:
-
你能把截图也发一下吗
-
尝试更改样式文件中的主题。您可以在这里分享您的样式文件代码,以便我为您提供帮助。
-
将
android:layout_alignBaseline="@id/label"改为android:layout_alignBaseline="@+id/label",android:layout_toRightOf="@id/label"改为android:layout_toRightOf="@+id/label",android:layout_toEndOf="@id/label" toandroid:layout_toEndOf="@+id/label" -
删除
android:layout_alignBaseline="@id/label" -
复制粘贴您的代码并运行应用程序。它就像一个魅力。也许你还有其他问题。尝试在任何其他设备上测试它
标签: android android-studio android-layout android-edittext