打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
layout

I am using a linear layout as a button however, I do not have anything assigned as clickable or not and it seems to work just fine. I have set up a style for my standard button and I just assign that style to the linear layout like I would any other button.

The linearlayout as a button:

<LinearLayout    style="@style/btn_stand"    android:layout_width="match_parent"    android:layout_height="wrap_content"    android:onClick="onClickLLButton"    android:orientation="vertical" >    <TextView        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:gravity="center"        android:text="Button Label" />    <TextView        android:id="@+id/tvLLButton"        android:layout_height="0px"        android:layout_weight="1"        android:gravity="center"        android:text="Button Info" /></LinearLayout>

My style definition for the button:

<style name="btn_stand" parent="AppBaseTheme">    <item name="android:background">@drawable/btn_stand_sel</item>    <item name="android:textColor">@drawable/btn_stand_text_color</item>    <item name="android:minHeight">48dp</item>    <item name="android:paddingLeft">5dp</item>    <item name="android:paddingRight">5dp</item></style>

My @drawable/btn_stan_sel file:

<?xml version="1.0" encoding="utf-8"?><selector xmlns:android="http://schemas.android.com/apk/res/android">    <!-- disabled state -->    <item android:drawable="@drawable/btn_stand_disabled" android:state_enabled="false"/>    <!-- enabled and pressed state -->    <item android:drawable="@drawable/btn_stand_pressed" android:state_enabled="true" android:state_pressed="true"/>    <!-- enabled and focused state -->    <item android:drawable="@drawable/btn_stand_focused" android:state_enabled="true" android:state_focused="true"/>    <!-- enabled state -->    <item android:drawable="@drawable/btn_stand_enabled" android:state_enabled="true"/></selector>

My drawable file repeated for each state just with different colors for each state:

<?xml version="1.0" encoding="utf-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android"    android:shape="rectangle" >    <stroke        android:width="1dp"        android:color="@color/stroke" />    <solid android:color="@color/blue" />    <corners android:radius="6dp" /></shape>
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
android中能不能放入gif动态图片,像qq登陆界面流动的云彩
自定义 RadioButton 选中和未选中时的图片
android 中ImageButton按下改变背景图片的效果
教程12 | 教你快速写一个Android程序
Android应用开发笔记(10):制作自定义背景Button按钮、自定义形状Button的全攻略
Android实训案例(一)——计算器的运算逻辑
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服