我想使用開源的天線應用作爲構建我的android應用程序的參考。我使用的ActionBarSherlock,並希望在我的佈局的底部創建一個按鈕,從一側延伸到另一側,沒有填充。它應該是這樣的:沒有填充的Android按鈕
我Styles.xml看起來是這樣的:
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="Theme.Application.Light" parent="@style/Theme.Sherlock.Light">
<item name="attr/non_transparent_background">@color/white</item>
<item name="attr/borderless_button">@drawable/borderless_button</item>
</style>
</resources>
borderless_button.xml看起來是這樣的:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true"><shape android:shape="rectangle">
<solid android:color="@color/selection_background_color_light" />
</shape></item>
<item android:state_focused="true"><shape android:shape="rectangle">
<solid android:color="@color/selection_background_color_light" />
</shape></item>
<item><shape android:shape="rectangle">
<solid android:color="@android:color/transparent" />
</shape></item>
</selector>
attrs.xml看起來是這樣的:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<attr name="borderless_button" format="reference" />
<!-- Used in itemdescription -->
<attr name="non_transparent_background" format="reference" />
</resources>
我的清單有這樣的:
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/Theme.Application.Light" >...</>
我的佈局是:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/footer"
style="@android:style/ButtonBar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="horizontal" >
<Button
android:id="@+id/butConfirm"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Search" />
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/queryString"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_margin="8dp"
android:focusable="true"
android:focusableInTouchMode="true"
android:text="What would you like to search for?" />
<EditText
android:id="@+id/etxtQueryString"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/queryString"
android:layout_margin="8dp"
android:hint="Enter Query"
android:inputType="textUri" />
</RelativeLayout>
</RelativeLayout>
什麼它結束了看起來像:
我只需要一個按鈕,但還是希望它覆蓋屏幕的整個寬度。
以下是我用作指導的源代碼的鏈接。 https://github.com/danieloeh/AntennaPod
任何幫助都會很棒!
感謝
我在你的XML中看到了一些利潤,你玩過這些數字嗎? – hagope
邊距僅用於textview和edittext,它們不影響按鈕。 – Nath5