Android的按键采用没有填充 [英] Android Button with No Padding
问题描述
我试图使用开源应用antennapod作为构建我的Android应用程序的参考。我使用ActionBarSherlock并想在我的布局,从侧面延伸,没有填充到另一侧的底部创建一个按钮。它应该是这样的:
我Styles.xml看起来是这样的:
<?XML版本=1.0编码=UTF-8&GT?;
<资源的xmlns:机器人=http://schemas.android.com/apk/res/android> <样式名称=Theme.Application.Light父=@风格/ Theme.Sherlock.Light>
<项目名称=ATTR / non_transparent_background> @色/白< /项目>
<项目名称=ATTR / borderless_button> @绘制/ borderless_button< /项目>
< /风格>< /资源>
borderless_button.xml看起来是这样的:
<选择的xmlns:机器人=http://schemas.android.com/apk/res/android>
<项目的android:STATE_ pressed =真正的><形状机器人:形状=矩形>
[固体机器人:色=@色/ selection_background_color_light/>
< /形状>< /项目>
<项目的android:state_focused =真正的><形状机器人:形状=矩形>
[固体机器人:色=@色/ selection_background_color_light/>
< /形状>< /项目>
<项目><形状机器人:形状=矩形>
[固体机器人:色=@机器人:彩色/透明/>
< /形状>< /项目>
< /选择>
attrs.xml看起来是这样的:
<?XML版本=1.0编码=UTF-8&GT?;
<资源> < attr指示NAME =borderless_button格式=参考/>
<! - 用于itemdescription - >
< attr指示NAME =non_transparent_background格式=参考/>< /资源>
我的清单有这样的:
<应用
机器人:allowBackup =真
机器人:图标=@绘制/ ic_launcher
机器人:标签=@字符串/ APP_NAME
机器人:主题=@风格/ Theme.Application.Light> ...< />
我的布局是:
<?XML版本=1.0编码=UTF-8&GT?;
<的RelativeLayout的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:layout_width =FILL_PARENT
机器人:layout_height =FILL_PARENT
机器人:方向=垂直> <的LinearLayout
机器人:ID =@ + ID /页脚
风格=@安卓风格/按钮栏
机器人:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_alignParentBottom =真
机器人:方向=横向> <按钮
机器人:ID =@ + ID / butConfirm
机器人:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT
机器人:文字=搜索/> < / LinearLayout中> < RelativeLayout的
机器人:layout_width =match_parent
机器人:layout_height =WRAP_CONTENT> <的TextView
机器人:ID =@ + ID /的queryString
机器人:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_alignParentTop =真
机器人:layout_margin =8DP
机器人:可聚焦=真
机器人:focusableInTouchMode =真
机器人:文字=你要什么搜索? /> <的EditText
机器人:ID =@ + ID / etxtQueryString
机器人:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_below =@ ID /的queryString
机器人:layout_margin =8DP
机器人:提示=输入查询
安卓的inputType =textUri/> < / RelativeLayout的>< / RelativeLayout的>
什么它结束了看起来像:
我只需要一个按钮,但仍希望它覆盖屏幕的整个宽度。
下面是链接到我使用为指导来源$ C $ C。
https://github.com/danieloeh/AntennaPod
任何帮助将是真棒!
感谢
<按钮
机器人:ID =@ + ID / butConfirm
机器人:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT
机器人:文字=搜索
机器人:背景=@空/>
这应该做的伎俩!
I am trying to use the open source antennapod application as a reference for building my android application. I am using ActionBarSherlock and want to create a button at the bottom of my layout that extends from side to side with no padding. It should look like this:
My Styles.xml looks like this:
<?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 looks like this:
<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 looks like this:
<?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>
My Manifest has this:
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/Theme.Application.Light" >...</>
My layout is:
<?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>
What it ends up looking like:
I just need one button but still want it to cover the whole width of the screen.
Here is the link to the source code I am using as a guide. https://github.com/danieloeh/AntennaPod
Any help would be awesome!
Thanks
<Button
android:id="@+id/butConfirm"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Search"
android:background="@null"/>
This should do the trick!
这篇关于Android的按键采用没有填充的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!