0
我是android studio的初學者。我正在創建一個簡單的項目,在該項目上單擊按鈕可更改文本字段中的文本。問題是,當我運行應用程序時,按鈕覆蓋了文本字段並在其上隱藏了文本。因此,我無法查看文本更改甚至默認文本。在主要xml文件中,該按鈕位於文本字段,這就是我想要的樣子。任何人都可以幫忙嗎?佈局設置有問題?當我運行應用程序時隱藏文本字段的按鈕
我是android studio的初學者。我正在創建一個簡單的項目,在該項目上單擊按鈕可更改文本字段中的文本。問題是,當我運行應用程序時,按鈕覆蓋了文本字段並在其上隱藏了文本。因此,我無法查看文本更改甚至默認文本。在主要xml文件中,該按鈕位於文本字段,這就是我想要的樣子。任何人都可以幫忙嗎?佈局設置有問題?當我運行應用程序時隱藏文本字段的按鈕
此行添加到您的按鈕標籤
android:layout_toEndOf = "@+id/textviewid"
,現在你的按鈕會顯示您的TextView
下面試試這個佈局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
android:layout_marginTop="10dp"/>
<Button
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_marginTop="25dp"
android:text="Click!"
android:textAllCaps="false"/>
</LinearLayout>
請發表您的代碼片段。 – DaveNOTDavid
當你去看醫生時,你只是告訴她你的身體很痛,並期待她知道如何幫助你?不,你告訴她你身體的哪部分受傷,並提供你遇到的症狀時的細節。同樣,我們需要更多細節才能提供幫助。有關如何提供這些詳細信息的建議,請參見[mcve]。 –