[英]need help in android layouts
您好我想創建一個必須在屏幕頂部具有EditText和Sibmit Button的布局,並且它們應該水平對齊並填充整個水平空間。
每當我進入縱向或橫向模式時,它都應該占據整個水平空間。 請指導。 我的應用程序此時卡住了
謝謝
你可以試試這個:
<RelativeLayout android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<Button android:id="@+id/btnSubmit" android:layout_width="wrap_content"
android:text="Submit"
android:layout_height="wrap_content" android:layout_alignParentTop="true"
android:layout_alignParentRight = "true" android:padding = "4dp" />
<EditText android:id="@+id/txtEdit" android:layout_width="fill_parent"
android:layout_toLeftOf="@id/btnSubmit"
android:layout_height="wrap_content" android:layout_alignTop="@id/btnSubmit"
android:layout_alignBottom = "@id/btnSubmit" android:padding = "4dp" />
</RelativeLayout>
希望能幫助到你 :)
注意:請查看此鏈接,它對您非常有幫助;) 了解Android中的用戶界面
簽出此鏈接
從中尋求幫助,並根據您的需要對其進行自定義。
我完成了權重= 1的工作。
<LinearLayout android:id="@+id/rl1" android:orientation="horizontal" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_below="@+id/message" >
<EditText android:id="@+id/search_bar" android:singleLine="true" android:hint="Search"
android:layout_width="fill_parent" android:layout_weight="1" android:layout_height="wrap_content"></EditText>
<Button android:id="@+id/search_submit" android:layout_height="wrap_content" android:layout_width="wrap_content"
android:layout_alignParentRight="true" android:text="Search"></Button>
</LinearLayout>
這很好。.請對這個答案進行投票,以便其他人也可以尋求幫助。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.