如何在Android的按钮点击android系统API 4.1背景颜色的变化? [英] how the background color changes on button click in android api 4.1 in android?

查看:214
本文介绍了如何在Android的按钮点击android系统API 4.1背景颜色的变化?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道,在点击按钮的背景颜色这里怎么改变,它发生超过按钮size..Can有人告诉Ë从哪里背景颜色来这?
Android的API 4.1,在道内: Android的API-RES-布局log_text_box_1.xml 文件看起来像这样。
    
    

 的Apache授权版本2.0(以下简称许可证);
     你可能不使用这个文件除了在遵守许可。
     您可以在获得许可证的副本          http://www.apache.org/licenses/LICENSE-2.0     除非适用法律要求或书面同意,软件
     该许可证下发布分布在原样的基础,
     无担保或任何形式的条件,无论是前preSS或暗示的保证。
     查看许可证的特定语言的管理权限和
     根据许可证的限制。
- ><的LinearLayout
    的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    机器人:方向=垂直
    机器人:layout_width =match_parent
    机器人:layout_height =match_parent>    <按钮
        机器人:ID =@ + ID /加
        机器人:layout_width =WRAP_CONTENT
        机器人:layout_height =WRAP_CONTENT
        机器人:文字=@字符串/ log_text_box_1_add_text/>    < com.example.android.apis.text.LogTextBox
        机器人:ID =@ + ID /文
        机器人:背景=@绘制/箱
        机器人:layout_width =match_parent
        机器人:layout_height =0dip
        机器人:layout_weight =1
        机器人:滚动条=垂直/>    <按钮
        机器人:layout_width =WRAP_CONTENT
        机器人:layout_height =WRAP_CONTENT
        机器人:文字=@字符串/ log_text_box_1_do_nothing_text/>< / LinearLayout中>


解决方案

这行为是河洛主题,对于这​​样的按钮选择使用位于路径到你的SDK \\平台\\ Android的默认的Andr​​oid风格的按钮-16 \\ DATA \\水库\\绘制的地名,如: btn_default_holo_dark.xml btn_default_holo_light.xml

用于第一选择器被拉伸是:

  btn_default_normal_holo_dark.9

  btn_default_disabled_holo_dark.9

  btn_default_disabled_focused_holo_dark.9

  btn_default_focused_holo_dark.9

  btn_default_ pressed_holo_dark.9

最后的9片图像是一个负责超过按钮的边框的效果,希望这是你在找什么。

I want to know that on button click how the background color changed here and it takes place more than the button size..Can anybody tell e that from where the background color is coming to this?? inside the android api 4.1, at path: Android API-res-layout-log_text_box_1.xml file looks like this.

     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>

解决方案

This behaviour is the default android style button for the Holo theme, the selector use for such buttons are located in Path to your sdk \platforms\android-16\data\res\drawable with names such as : btn_default_holo_dark.xml and btn_default_holo_light.xml

the drawable used for the first selector are :

btn_default_normal_holo_dark.9

btn_default_disabled_holo_dark.9

btn_default_disabled_focused_holo_dark.9

btn_default_focused_holo_dark.9

btn_default_pressed_holo_dark.9

The last 9-patch image is the one responsible for the effect of exceeding the button's borders, hope that's what you are looking for.

这篇关于如何在Android的按钮点击android系统API 4.1背景颜色的变化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆