[英]Android relative layout problem
我只是無法在屏幕底部顯示按鈕。 我有2個textviews和2個edittexts設置為走了,當用戶單擊復選框時它們變為可見。 只有這樣我的按鈕才能正確放置,否則在我的應用程序啟動時它就位於應用程序的頂部。(請參閱此處: http : //www.shrani.si/f/3V/10G/4nnH4DtV/layoutproblem.png )還嘗試了android:layout_alignParentBottom =“ true”,但這都沒有幫助。
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/scrollview"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="wrap_content">
<TextView android:id="@+id/txt1" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:text="Krajevna skupnost: "
android:layout_alignParentTop="true" />
<Spinner
android:id="@+id/spinner1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:prompt="@string/ks_prompt"
android:layout_below="@id/txt1"
/>
<TextView android:id="@+id/txt2" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:text="Zadeva: "
android:layout_below="@id/spinner1" />
<Spinner
android:id="@+id/spinner2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:prompt="@string/pod_prompt"
android:layout_below="@id/txt2"
/>
<TextView android:id="@+id/tv1" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:text="Zadeva: "
android:layout_below="@id/spinner2" />
<EditText android:id="@+id/prvi" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_below="@id/tv1" />
<TextView android:id="@+id/tv2" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_below="@id/prvi"
android:text="Vsebina: " />
<EditText android:id="@+id/drugi" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_below="@id/tv2" />
<CheckBox android:id="@+id/cek" android:text="Obveščaj o odgovoru"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_below="@id/drugi" />
<TextView android:id="@+id/tv3" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_below="@id/cek"
android:text="Email: "
android:visibility="gone"/>
<EditText android:id="@+id/tretji" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_below="@id/tv3"
android:visibility="gone" />
<TextView android:id="@+id/tv4" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_below="@id/tretji"
android:visibility="gone"
android:text="Telefon: " />
<EditText android:id="@+id/cetrti" android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:visibility="gone"
android:layout_below="@id/tv4" />
<Button android:id="@+id/gumb"
android:text="Klikni"
android:typeface="serif" android:textStyle="bold"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_below="@id/cetrti" />
</RelativeLayout>
</ScrollView>
刪除ScrollView並將android:layout_alignParentBottom =“ true”設置為您的底部按鈕。 還要刪除以下行:android:layout_below =“ @ id / cetrti”。 如果您確實需要ScrollView,則可以使用以下方法:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<ScrollView
...
<RelativeLayout
...
</RelativeLayout>
</ScrollView>
<Button
android:layout_alignParentBottom="true"
...
</RelativeLayout>
我在2.1設備上運行它-看起來還不錯。 按鈕位於復選框下方。 所以我不確定是什么問題。 作為可以肯定起作用的快速解決方案-將相對布局更改為LinearLayout。 有點貴,但是為了您的目的,IMO應該可以工作
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.