Android布局重量我是Android開發(fā)的新手,我有一個關于在線性布局中設置權(quán)重的問題。我正在嘗試使用兩個自定義按鈕和自定義編輯文本創(chuàng)建一行。編輯文本應占用與其內(nèi)容相同的空間,并且兩個按鈕應水平擴展以填充行中的其余可用空間。像這樣...| [#Button++#] [#Button--#] [et] |經(jīng)過幾次嘗試,這是我能得到的最接近的東西,盡管看起來過于復雜。| [Button] [Button] [###ET###] |<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal|center_vertical"
android:layout_weight="1"
>
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_horizontal|center_vertical"
>
<RelativeLayout
android:id="@+id/btn_plus_container"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<ImageButton
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:id="@+id/btn_plus"
android:background="@drawable/btn"
android:layout_centerInParent="true"
></ImageButton>
<TextView
android:textColor="#FAFAF4"
android:id="@+id/tv_dice_plus"
android:text="@string/tv_plus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
></TextView>
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_horizontal|center_vertical"
>據(jù)我所知設置[android:layout_weight =“2”]為線性布局按住按鈕應該使它們占用比編輯文本更多的空間,但它對我來說卻相反,使它們都是一半大小。| [Btn] [Btn] [#####et#####] |我已經(jīng)嘗試了很多不同的組合,我甚至都記不住它們,但沒有一個有效。
- 3 回答
- 0 關注
- 383 瀏覽
添加回答
舉報
0/150
提交
取消