Android 单击“图像视图”时中心阴影
当按下“状态”时,我试图在中心显示圆形阴影。 但在目前的情况下,它提供了全视图(矩形)阴影。 这是我正在尝试的。。。 1.left_button.xmlAndroid 单击“图像视图”时中心阴影,android,xml,layout,Android,Xml,Layout,当按下“状态”时,我试图在中心显示圆形阴影。 但在目前的情况下,它提供了全视图(矩形)阴影。 这是我正在尝试的。。。 1.left_button.xml <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_pressed="true"> <shap
<?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="#ffffff"></solid>
</shape>
</item>
<item android:state_focused="true"><shape>
<solid android:color="#40454a"></solid>
</shape></item>
<item><shape>
<solid android:color="#40454a"></solid>
</shape></item>
</selector>
这是我正在应用的xml布局
<RelativeLayout
android:id="@+id/relative_activity_camera_bottom"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:gravity="center_vertical"
android:background="@layout/footer_color" >
<LinearLayout
android:id="@+id/bottom_layout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:background="@android:color/transparent"
android:gravity="center_vertical"
android:weightSum="1.0" >
<ImageView
android:id="@+id/captureImage"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="0.5"
android:background="@layout/left_button"
android:src="@layout/camera_image"
/>
<ImageView
android:id="@+id/recordButton"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="0.5"
android:src="@layout/videocamera_image"
android:background="@layout/left_button"
android:onClick="startRecording"
/>
</LinearLayout>
</RelativeLayout>
原始条件-
当前案例-(但我只想在中间显示白色)例如,使用选择器:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/gradient_round_press_effect" android:state_selected="true" android:state_window_focused="false"/>
<item android:drawable="@drawable/gradient_round_press_effect" android:state_selected="true"/>
<item android:drawable="@drawable/gradient_round_press_effect" android:state_pressed="true" android:state_selected="false"/>
<item android:drawable="@drawable/gradient_round_press_effect_inverse" android:state_selected="false"/>
</selector>
对于两个可绘制形状,单击第一个形状时(渐变\圆形\按压\效果):
根据按钮的大小调整半径的大小
对于起始颜色,如果您想要白色,请使用#66FFFFFF(66表示透明度)
对于末端颜色,也许可以使用透明?我没试过这个
当不点击时,定义你自己的颜色(渐变\圆形\按压\效果\反转)不是真正的“反转”,但这是另一个渐变的例子。你可以用一种颜色来代替
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<gradient
android:angle="270"
android:centerColor="@color/clr_gradient2"
android:endColor="@color/clr_gradient1"
android:startColor="@color/clr_gradient3"
android:type="linear" />
</shape>
这是您需要的吗:不,我想让您感觉我已将按钮点击到了某个有限的区域@heLL0An建议:与其使用imageview,不如使用ImageButton查看“src”中的图标和“background”中的选择器,以获得有价值的建议按下按钮时仍显示fullview白色。。。如上图所示,如果您正在使用我的方法,请尝试减小梯度中心,我不知道您使用的颜色可能会尝试更改它们以用于测试
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<gradient
android:angle="270"
android:centerColor="@color/clr_gradient2"
android:endColor="@color/clr_gradient1"
android:startColor="@color/clr_gradient3"
android:type="linear" />
</shape>