android按下效果
Ⅰ android listview 如何實現這種圓角和按下的效果,送分題又來了,求高手快來拿分
靠布局和一點小邏輯就可以做到,具體就是列表正文其實左右有個Margin值,而上面的透明覆蓋層,左右是抵滿的,這樣一來就很簡單了。
可以看我附件的demo,顏色我沒調好,我很不擅長調顏色。但是效果差不多的。
Ⅱ Android默認的button都有按下的效果,為什麼換了顏色後默認的按下效果就消失了這是某個屬
你換的是background的顏色吧。Button默認background是一個選擇器,你自己寫一個選擇器,然後設置為background就好了。
Ⅲ android xml實現按鈕的圓角、陰影效果以及按下變化效果
5個xml文件實現 按鈕的圓角、陰影效果以及按下變化效果
Ⅳ Android 按鈕點擊觸摸按壓效果
//加入這個即可
android:background="?android:attr/selectableItemBackground"
Ⅳ android 怎麼實現按下顯示不同顏色,又有波紋效果
ripple嵌套selector
<?xmlversion="1.0"encoding="utf-8"?>
<ripplexmlns:android="http://schemas.android.com/apk/res/android"
android:color="#FF0000">
<item>
<selector>
<item
android:drawable="@drawable/icon_pressed"
android:state_pressed="true">
</item>
<item
android:drawable="@drawable/icon_normal"
android:state_pressed="false">
</item>
</selector>
</item>
Ⅵ android中如何設置圖片按鈕的點擊效果,就是一點擊圖片,會顯示一種被按下去的感覺,而不是買有任何反應
可以使用這樣的一個xml布局
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
// 獲取焦點時候按鈕的背景狀態
<item android:drawable="@drawable/btn_green_pressed" android:state_enabled="true" android:state_focused="true"/>
// 被按下時候按鈕的背景狀態
<item android:drawable="@drawable/btn_green_pressed" android:state_enabled="true" android:state_pressed="true"/>
//正常狀態下按鈕的狀態
<item android:drawable="@drawable/btn_green_normal"/>
</selector>
把按鈕的背景設置為這個布局引用就行了.試試吧騷年
Ⅶ android怎麼設置button按下去的效果
可以用兩張不同的圖片,不按下的顯示為一種顏色,按下去顯示為另一種顏色,兩張圖片即可實現。
Ⅷ 安卓按鈕按下效果怎麼設置呢怎麼設置按鈕圓角和按下效果
可以通過shape設置圓角
<?xml version="1.0" encoding="utf-8"?>
<!-- shape如果不聲明形狀默認是正方形 -->
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<!-- 設置圓角 -->
<corners android:radius="2dp" >
</corners>
<!-- 設置填充色 -->
<solid android:color="#4285f4" >
</solid>
<!-- 設置邊框的顏色和寬度 -->
<stroke
android:width="1dp"
android:color="#4285f4" >
</stroke>
</shape>
通過selector設置點擊效果
button_bg.xml
<?xml version="1.0" encoding="utf-8"?>
<!-- 這個是用於控制按鈕組背景的文件 -->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- **點擊時效果**********背景引用的資源*************************是否獲得焦點*********************是否按下******* -->
<item android:drawable="@drawable/button_p" android:state_focused="true" android:state_pressed="false"/>
<item android:drawable="@drawable/button_p" android:state_focused="true" android:state_pressed="true"/>
<item android:drawable="@drawable/button_p" android:state_focused="false" android:state_pressed="true"/>
<!-- **************沒有任何操作時顯示的背景************** -->
<item android:drawable="@drawable/button_n"></item>
</selector>
在xml文件中設置button的background屬性。
android:background="@drawable/button_bg"
Ⅸ android 的Button怎樣自動觸發按下的動作
android 的Button自動觸發按下的動作需要在Button添加android:onClick="click"屬性,click為方法名,使用步驟如下:
1、使用Android studio創建一個Android項目並打開布局文件,在布局文件中添加一個Button,並設置android:onClick="click",如下圖:
Ⅹ Android——點擊按鈕的陰影動畫
使用translationZ的屬性使按鈕在z軸方向上移,並且設置上移的時間,產生懸浮動畫的效果。
再次使用translationZ設置按鈕在z軸方向下移,回到原位。
效果: