我試圖創建一個更好看的按鈕欄爲我的應用程序來匹配主題。 到目前爲止,我使用下面的代碼:三個按鈕RelativeLayout與視圖分隔線
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/footer"
style="@android:style/ButtonBar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="bottom"
android:orientation="horizontal" >
<Button
android:id="@+id/Formula"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Formula" />
<Button
android:id="@+id/Solve"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Solve" />
<Button
android:id="@+id/Clear"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Clear" />
</LinearLayout>
,它給了我這樣的結果:
我也在工作的一些代碼有更好看,以取代酒吧一。這是因爲如下:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_alignParentBottom="true" >
<View
android:layout_width="match_parent"
android:layout_height="1dip"
android:layout_alignParentTop="true"
android:layout_marginLeft="4dip"
android:layout_marginRight="4dip"
android:background="@drawable/black_white_gradient" />
<View
android:id="@+id/ViewOne"
android:layout_width="1dip"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="4dip"
android:layout_marginTop="4dip"
android:background="@drawable/black_white_gradient" />
<Button
android:id="@+id/ButtonOne"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_toLeftOf="@id/ViewOne"
android:background="@color/button_blue_background"
android:paddingTop="5dp"
android:text="Cancel"
android:textColor="@color/button_dark_text" />
<Button
android:id="@+id/ButtonTwo"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_toRightOf="@id/ViewOne"
android:background="@color/button_blue_background"
android:text="OK"
android:textColor="@color/button_dark_text" />
</RelativeLayout>
導致:
所以我的問題是,我無法獲得新的黑條上有三個按鍵。我試着用android:layout_toRightOf屬性添加更多的視圖和按鈕,但它仍然不起作用。 有什麼想法可以做到這一點?
我喜歡你的解決方案,但它並沒有真正的工作。 這是發生了什麼:http://i49.tinypic.com/2ezpvlj.png 由於我的按鈕是透明的,直到點擊和漸變看起來相當奇怪。 – Pkmmte 2012-07-10 23:56:30
理想是讓按鈕上方的水平線漸變,對嗎?漸變呈現所有的LinearLayout高度,但您可以定義漸變的正確高度,看起來像2或3dp。 – yugidroid 2012-07-11 00:04:47
我編輯了我的答案,請檢查出來。我認爲這可能會對你有所幫助。 – yugidroid 2012-07-11 00:15:18