我想留下一个ImageButton被禁用(不可点击)但已经使用过但android: enabled = "false"不起作用.
有谁知道如何禁用的ImageButton?
我有带有CommandArgument属性的ImageButton,它具有多个Eval值.当我单击其中一个时,我想将值传递给ImageButton2_Click事件,但它不起作用,因为Command参数为null.
<div class="sag-re-icerik" id="icerik2" runat="server">Lorem ipsum dolor sit amet, consectetur commodo et convallis et, auctor viverra metus. Aenean pharetra, arcu nec viverra mollis, turpis neque feugiat massa, non dapibus neque nunc ac orci. </div>
<div class="oy-verme">
<div class="yildiz"><asp:ImageButton ID="ImageButton4" runat="server" Height="19px" ImageUrl="~/images/yildiz.png" onclick="ImageButton2_Click" Width="20px" style="position: relative; top: 13px; left:6px; float:left; " commandArgument='<%#Eval("sdasdas") + ","+Eval("fafasfa") %>' /></div>
<div class="yildiz"><asp:ImageButton ID="ImageButton5" runat="server" Height="19px" ImageUrl="~/images/yildiz.png" onclick="ImageButton5_Click" Width="20px" style="position: relative; top: 13px; left:8px; float:left;" commandArgument='<%#Eval("row[0].ToString()") + ","+Eval("row[1].ToString()") %>'/></div>
<div class="yildiz"><asp:ImageButton ID="ImageButton6" runat="server" Height="19px" ImageUrl="~/images/yildiz.png" …Run Code Online (Sandbox Code Playgroud) 我试图在Android ImageButton上圆角,代码看起来像这样;
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageButton"
android:layout_marginTop="57dp"
android:src="@drawable/friends"
android:padding="1dp"
android:layout_alignParentTop="true"
android:layout_toLeftOf="@+id/imageButton2"
android:layout_marginRight="62dp" />
</RelativeLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
基本上我们的输出是一个ImageButton,但它有方角,我们试图圆角.
谢谢
我想在xml文件中创建一个带有背景图像的Android ImageButton,并在其中间放置一个较小的图标,位于中心.出于某种原因,如何做到这一点并不明显,文档也无济于事.
<ImageButton
android:id="@+id/sound_button"
android:layout_x="430px"
android:layout_y="219px"
android:layout_width="48px"
android:layout_height="48px"
android:scaleType="center"
android:src="@android:drawable/volumeicon"
android:background="@drawable/clearbuttonup"
/>
Run Code Online (Sandbox Code Playgroud)
但是,无论我尝试什么(在layout _ height和layout _ width上放置" wrap _ content "而不是绝对数字,图标仍保留在按钮的左上角.但是,如果我没有背景图像(即一个系统默认的白色按钮),图标会进入中心.当我使用颜色而不是图像作为背景时,按钮也会进入左上角.
为什么会发生这种情况,我将如何实际获得我想要的行为 - 也就是说,中心带有图标的背景图像?
任何人都可以告诉我如何调整imageButton的大小以使图像精确拟合.这是我尝试的代码,但图像放置在我定位的位置,
imageButton但我无法减小imageButton的大小,请帮我纠正这个问题...我试过的代码是......
<ImageButton>
android:id="@+id/Button01"
android:scaleType="fitXY" // i have tried all the values for this attr
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:cropToPadding="false"
android:paddingLeft="10dp"
android:src="@drawable/eye"> // this is the image(eye)
</ImageButton>
Run Code Online (Sandbox Code Playgroud) 这看起来很简单,但我无法禁用ImageButton.它继续接收点击事件,其外观不会像标准的Button那样改变.
关于SO 有一些类似的问题,但它们对我没有帮助.
即使有这样一个非常简单的布局:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<ImageButton
android:id="@+id/btn_call"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:clickable="false"
android:enabled="false"
android:src="@android:drawable/sym_action_call" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
该按钮仍然启用,我可以单击它.
奇怪的是,如果我将其更改ImageButton为简单Button,那么它将按预期工作.该按钮变为禁用且无法点击.我不明白.有没有人有想法?
这张图片可以帮助您理解我的问题:

我想把里面显示的图像拉伸ImageButton到整个区域ImageButton.正如您所看到的,数字1的图片只占大约95%,ImageButton你也可以看到它的边界ImageButton.
我还是想保持图像按钮的样式
这是我使用ImageView的方式:
<ImageButton
android:id="@+id/secondActivityBbuttonDownRight"
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:scaleType="fitStart"
android:src="@drawable/111" />
Run Code Online (Sandbox Code Playgroud)
我想我发现了我的问题.我需要一个只包含图像并具有单击效果的自定义组件.
我想以编程方式删除ImageButton中的灰色背景.我试过很多方法来删除它 - 如 -
imageButton.setBackgroundDrawable(null);
Run Code Online (Sandbox Code Playgroud)
但是在实现它们时,我没有在触摸时对ImageButton产生连锁反应.(触摸时不突出显示).
有没有办法删除背景但保留涟漪效果或突出显示.