zoukankan      html  css  js  c++  java
  • android教程之设置Button的UI

         android系统默认的button视觉效果并不好看,但是别担心,android为我们留了点后路,让我们可以修改button的颜色/形状,以此适用我们自己的应用.

       我们再drawable-hdpi中新建一个button-style.xml

    <?xml version="1.0" encoding="utf-8"?>
    <selector xmlns:android="http://schemas.android.com/apk/res/android" >
        <!-- 当按钮按下时,按钮的样式会改变 -->
        <item
            android:state_pressed="true">
        	<shape >
        	    <solid android:color="#236754"/>
        	    <stroke 
        	        android:width="2dp"
        	        android:color="#098767"/>
        	    <corners 
        	        android:topLeftRadius="10dp"
        	        android:topRightRadius="0dp"
        	        android:bottomLeftRadius="10dp"
        	        android:bottomRightRadius="0dp">
        	        
        	    </corners>
        	</shape>    
            
        </item>
    
    </selector>

    button.xml

    <Button 
            android:id="@+id/bt"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/button_style"
            android:text="@string/button"/>
    	<TextView 
    	    android:id="@+id/text2"
    	    android:layout_width="match_parent"
    	    android:layout_height="wrap_content"/>

    运行你的应用,按下您自定义的按钮,你会发现专属您的按钮.


  • 相关阅读:
    Django路由系统
    修改数据库时区问题
    Django框架篇
    前端css
    前端html
    前端初识
    数据库3
    数据库2
    数据库1
    数据库初识
  • 原文地址:https://www.cnblogs.com/IntelligentBrain/p/5111302.html
Copyright © 2011-2022 走看看