在 Android 中更改焦点线性布局的背景?
我有线性布局,其背景设置为 rect.xml,如下所述。此布局的方向是垂直的。
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<solid android:color="#ffffff"/>
<stroke android:width="1dp"
android:color="#bbbbbb"/>
<corners android:radius="10px"/>
</shape>
还有另外两个线性布局作为上述线性布局的子级。我想要的是,孩子的线性焦点应该在焦点上和按下时改变。我创建了一个项目选择器文件,并将其添加为子线性布局的背景,但这使得矩形的边框隐藏。
谁能让我知道该怎么做?
I have the linearlayout which has the background set as rect.xml as mentioned below. The orientation of this layout is vertical.
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<solid android:color="#ffffff"/>
<stroke android:width="1dp"
android:color="#bbbbbb"/>
<corners android:radius="10px"/>
</shape>
There are two other linearlayouts as child of the above linearlayout. What I want is that the child linearlyouts focus should be changed on focus and when pressed. I have created one item selector file and added that as the background of the child linearlayouts but that makes the border of the rectangle hidden.
Can anyone let me know how to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用状态列表可绘制并提供不同的background.xml
http://developer .android.com/guide/topics/resources/drawable-resource.html#StateList
Use state list drawable and provide different background.xml
http://developer.android.com/guide/topics/resources/drawable-resource.html#StateList