在android api 4.1中,点击按钮时背景颜色如何变化?

在android api 4.1中,点击按钮时背景颜色如何变化?,android,Android,我想知道,在点击按钮时,背景颜色是如何变化的,而变化的幅度超过了按钮的大小。有人能告诉我背景颜色是从哪里来的吗?? 在android api 4.1内部,路径:android api-res-layout-log\u text\u box\u 1.xml文件如下所示。 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compl

我想知道,在点击按钮时,背景颜色是如何变化的,而变化的幅度超过了按钮的大小。有人能告诉我背景颜色是从哪里来的吗??
在android api 4.1内部,路径:android api-res-layout-log\u text\u box\u 1.xml文件如下所示。
     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <Button
        android:id="@+id/add"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/log_text_box_1_add_text"/>

    <com.example.android.apis.text.LogTextBox
        android:id="@+id/text"
        android:background="@drawable/box"
        android:layout_width="match_parent"
        android:layout_height="0dip"
        android:layout_weight="1"
        android:scrollbars="vertical"/>

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/log_text_box_1_do_nothing_text"/>

</LinearLayout>
根据Apache许可证2.0版(“许可证”)获得许可;
除非遵守许可证,否则不得使用此文件。
您可以通过以下方式获得许可证副本:
http://www.apache.org/licenses/LICENSE-2.0
除非适用法律要求或书面同意,软件
根据许可证进行的分发是按“原样”进行分发的,
无任何明示或暗示的保证或条件。
请参阅许可证以了解管理权限和权限的特定语言
许可证下的限制。
-->

此行为是Holo主题的默认android风格按钮,用于此类按钮的选择器位于sdk\platforms\android-16\data\res\drawable路径中,名称如下:
btn\u default\u Holo\u dark.xml
btn\u default\u Holo\u light.xml

第一个选择器所用的可拔模件包括:

btn_default_normal_holo_dark.9


最后一张9-patch图像是造成按钮边界超出效果的图像,希望这就是您要找的。

抱歉,我无法理解您想要从哪里复制此布局?您要找@drawable/box吗?Android API-res-layout-log\u text\u box\u 1.xml.Android API-res-layout-log\u text\u box\u 1.xml。我从这里复制了它。为了获得更多的可能性,请从android sdk运行android API演示,然后转到文本日志文本框。在此之后,新活动将通过两个按钮打开,第一个按钮是ADD,另一个按钮是Do Nothing。当你点击任何一个按钮时,你会看到该按钮的背景颜色正在改变,但是改变颜色比按钮占用更多的空间。这是为什么以及如何发生的??这正是我的问题。如果您对此有所了解,请回复。提前谢谢…谢谢你的回答。我会查出来的。坦克alot@user1395259drawable位于android sdk\platforms\android-16\data\res\drawable mdpi的路径中,欢迎使用!!
     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <Button
        android:id="@+id/add"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/log_text_box_1_add_text"/>

    <com.example.android.apis.text.LogTextBox
        android:id="@+id/text"
        android:background="@drawable/box"
        android:layout_width="match_parent"
        android:layout_height="0dip"
        android:layout_weight="1"
        android:scrollbars="vertical"/>

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/log_text_box_1_do_nothing_text"/>

</LinearLayout>
btn_default_disabled_focused_holo_dark.9
btn_default_focused_holo_dark.9
btn_default_pressed_holo_dark.9