Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/196.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 单击和长按按钮时,在线性布局中添加阴影_Android_Xml_Android Layout_Android Studio - Fatal编程技术网

Android 单击和长按按钮时,在线性布局中添加阴影

Android 单击和长按按钮时,在线性布局中添加阴影,android,xml,android-layout,android-studio,Android,Xml,Android Layout,Android Studio,我想知道是否有人可以使线性布局像一个按钮。我确实允许 android:clickable="true" android:focusable="true" 一切正常,只是它没有按钮的主要功能,当我们点击或长按按钮时,按钮上的阴影。请帮我解决这个问题。试试这个: 您可以像按钮一样设置线性布局的按下状态 按钮_state.xml //按下时显示背景 //线性图像的默认背景 尝试在xml中的LinearLayout后台属性中设置此属性: android:background="?android:at

我想知道是否有人可以使线性布局像一个按钮。我确实允许

android:clickable="true"
android:focusable="true"
一切正常,只是它没有按钮的主要功能,当我们点击或长按按钮时,按钮上的阴影。请帮我解决这个问题。

试试这个: 您可以像按钮一样设置线性布局的按下状态

按钮_state.xml

//按下时显示背景
//线性图像的默认背景

尝试在xml中的LinearLayout后台属性中设置此属性:

android:background="?android:attr/selectableItemBackground"

谢谢你的回答。。。这很好,但伙计,我有一个小问题,因为我是一个初学者…在我的线性布局中,我已经使用了一个可绘制的背景来勾勒我的布局现在我该如何污染这个可绘制的到那个。我不明白你的想法。你应该发布你的布局。