我正在尝试使用ImageButton控件进行客户端脚本执行.我可以使用OnClientClick属性指定要执行的客户端脚本,但是如何阻止它在每次用户单击时尝试发布?单击此按钮时没有理由发布.我已将CausesValidation设置为False,但这不会阻止它发布.
我有一个我正在尝试布局的屏幕......
基本上,我试图在屏幕上垂直均匀分布4个ImageButton对象...我在这里使用它来均匀分布项目,但现在我有一个可怕的时间来缩放图像但保持纵横比......如果我使用scaleType="centerInside"它们不缩放,如果我使用"fitXY"它们不保持纵横比...这里是布局的样子:

这是代码:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_margin="0dp"
android:padding="0dp"
android:orientation="vertical"
android:weightSum="5"
>
<ImageButton android:id="@+id/share_song"
android:layout_width="fill_parent" android:text=""
android:layout_marginLeft="0dp"
android:layout_marginTop="15dp"
android:layout_marginRight="5dp"
android:layout_marginBottom="5dp"
android:gravity="left"
android:src="@drawable/share_song_button_sel"
android:adjustViewBounds="true"
android:background="#0000"
android:scaleType="fitXY"
android:layout_height="0dp"
android:layout_weight="1"
/>
<Button
android:layout_width="wrap_content"
android:text="" android:id="@+id/tag_a_song"
android:layout_marginLeft="5dp"
android:layout_marginTop="10dp"
android:layout_marginRight="0dp"
android:layout_marginBottom="5dp"
android:gravity="right"
android:layout_gravity="right"
android:background="@drawable/song_check_in_button_sel"
android:layout_height="0dp"
android:layout_weight="1"
/>
<Button android:id="@+id/match_button"
android:layout_width="wrap_content" android:text=""
android:layout_marginLeft="0dp"
android:layout_marginTop="10dp"
android:layout_marginRight="0dp"
android:layout_marginBottom="5dp"
android:gravity="left"
android:background="@drawable/music_match_button_sel"
android:layout_height="0dp"
android:layout_weight="1"
/>
<Button android:id="@+id/friends_button"
android:layout_width="wrap_content" android:text=""
android:layout_marginLeft="0dp"
android:layout_marginTop="10dp"
android:layout_marginRight="0dp"
android:layout_marginBottom="5dp"
android:gravity="right"
android:layout_gravity="right"
android:background="@drawable/my_friends_music_button_sel"
android:layout_height="0dp"
android:layout_weight="1"
/>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal"
android:layout_marginRight="0dp" …Run Code Online (Sandbox Code Playgroud) 我希望在我的Android应用程序中,在ImageButton按下和释放时更改其图像,并且当再次按下它时,图像ImageButton将被更改回来,如何做到这一点?
我是android的新手并且陷入了一个非常基本的问题.我正在开发一个应用程序,我需要在fling上刷图像.在每个图像上我都要动态添加按钮.我使用AddContentView()添加按钮来添加按钮.一切都运行正常,但我想动态设置按钮的位置.我已经在很多地方读过,每个人都在使用addView()来添加按钮并设置它们的位置.我试过这个
但它没有工作.任何人都可以告诉我如何使用addContentView()设置按钮的边距(位置).任何帮助将非常感激.
我有一个透明的ImageButton.单击时,按钮的ImageResource设置为drawable-hdpi文件夹中的drawable(基本上图像显示在透明ImageButton的顶部).我正在使用这种ImageButton.setImageResource()方法来做到这一点.我的问题是,如何删除图像资源,以便再次只有透明图像按钮.当然,我需要能够在java中执行此操作,而不是XML.我尝试了以下ImageButton.setImageResource(null); 无效的方法:我也看了一下,找不到答案......提前感谢您的帮助.
编辑:谢谢大家的回答.PéterVarga的回答正是我所需要的,所以这就是我的目标.
任何人都可以告诉我如何避免在圆形按钮的圆圈外按压,因为"wrap_content"似乎不起作用.我使用图像文件来创建按钮.我感谢任何帮助.谢谢.
我有一个看起来像这样的ImageButton.
<ImageButton
android:id="@+id/ImageButton"
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_gravity="center"
android:layout_marginBottom="6px"
android:layout_marginRight="3px"
android:layout_toRightOf="@+id/Logo"
android:background="@drawable/button_bg_purple"
android:scaleType="fitStart"
android:src="@drawable/ImageButton" />
ImageButton ImgButton= (ImageButton) this.findViewById(R.id.ImageButton);
Run Code Online (Sandbox Code Playgroud)
现在我需要以编程方式在ImageButton中添加动态文本,我不能使用按钮.我该怎么做?
提前致谢 ...
当用户的焦点到达ImageButton时,是否可以指定不同的图像?我想在LinearLayout上显示图像按钮,并在用户的焦点出现在按钮上或用户按下按钮时更改图像.
谢谢.
我对Android中的动画(以及其他任何东西)都很陌生.有没有办法动画ImageButton?我只是想有时旋转按钮.就这样.有帮助吗?
谢谢.
我需要在我的android应用程序中创建这样排列的2个按钮:


但问题是我创建的按钮不是一个完美的三角形按钮.实际上它是一个方形按钮,图像设置为背景.在这种情况下,存在一个问题,即图像附近的白色区域是可点击的,我希望按钮更接近.这意味着两个按钮之间的空白区域必须被消除到最大.当我使用相对布局时,问题是,当我点击1按钮时,有时另一个按钮也会自动被点击.这是因为一个按钮与另一个按钮重叠.因此,如果不重叠按钮,我希望这两个按钮非常接近,实际上它们看起来像平行四边形.所以我的问题是如何将矩形按钮的形状更改为三角形按钮,以便可以排列两个按钮以这种方式看起来像平行四边形.任何人的帮助都很容易受到赞赏?我不知道从哪里开始.所以对编码部分的一点帮助很容易理解.谢谢提前..
imagebutton ×10
android ×9
animation ×1
asp.net ×1
aspect-ratio ×1
button ×1
drawable ×1
eclipse ×1
layout ×1
layoutparams ×1
post ×1
postback ×1
scale ×1
submit ×1