没有填充的 Android 按钮

标签 android button actionbarsherlock android-styles

我正在尝试使用开源 antennapod 应用程序作为构建我的 android 应用程序的引用。我正在使用 ActionBarSherlock 并想在我的布局底部创建一个按钮,该按钮从一侧延伸到另一侧而没有填充。它应该看起来像这样:

enter image description here

我的 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>

我的 list 有这个:

<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>

它最终看起来像什么:

enter image description here

我只需要一个按钮,但仍希望它覆盖整个屏幕宽度。

这是我用作指南的源代码链接。 https://github.com/danieloeh/AntennaPod

任何帮助都会很棒!

谢谢

最佳答案

<Button
        android:id="@+id/butConfirm"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="Search"
        android:background="@null"/>

这应该可以解决问题!

关于没有填充的 Android 按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13964748/

相关文章:

css - Twitter Bootstrap 按钮 - 悬停时打破背景

android - 将 google-play-services 库导入 Intellij IDEA 12(和 13)

java - 当使用 Intent 启动其他 Activity 时,单选按钮如何保持选中状态?

java - 在opengl es android中的随机位置绘制多个立方体

android - 如何通过 Intent 添加名字和姓氏的联系人

Objective-C 在运行时向我的 iPhone 应用程序添加 NSButton

javascript - onClick 按钮只工作一次

android - 无法删除布局边距

Android 设备选择器在目标列中显示红色 X

android - 无法解析 Landroid/support/v4/app/FragmentActivity 的父类(super class)