创建 IImageButton 并添加到工具条中:
ImageButton imageButton1 = new ImageButton();
toolstrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
imageButton1});
Run Code Online (Sandbox Code Playgroud)
崩溃错误
错误 1 无法将类型“lient.userControl.ImageButton”隐式转换为“System.Windows.Forms.ToolStripItem”E:\net_project\trunk\Client\Client\userControl\ToolBox.cs 29 15 客户端
我的图像按钮^
public partial class ImageButton : PictureBox, IButtonControl
{
#region Consturctor
public ImageButton()
{
InitializeComponent();
}
public ImageButton(IContainer container)
{
container.Add(this);
InitializeComponent();
}
#endregion
private bool isDefault = false;
private bool isHover = false;
private bool isDown = false;
#region IButtonControl Members
private DialogResult m_DialogResult;
public DialogResult DialogResult
{
get
{
return m_DialogResult;
}
set
{
m_DialogResult = value;
}
} …
Run Code Online (Sandbox Code Playgroud) 我已经搜索了网站和其他几个人,我遇到了一个问题,找到一种方法来制作一个清晰漂亮的图标风格的图像按钮.我一直使用的图像按钮填充内容,看起来只是扭曲,我想要非常好看的图标样式图像按钮,而不是它的污迹印章清晰度很低.我希望它们间隔足够你可以看到它们背后的背景,我是否需要以某种方式使src成为图像和背景清晰?
继承了我的一些代码:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/debface"
>
<TableLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="4"
android:gravity="bottom"
>
<!-- Images coming out Blurry, I need to compress like a hires icon file -->
<TableRow>
<ImageButton
android:id="@+id/button01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/debraidcard"
android:layout_weight="1"
android:padding="25px"
android:paddingLeft="25px"
android:paddingRight="25px"
/>
<ImageButton
android:id="@+id/button02"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/debraidcard"
android:padding="25px"
android:paddingLeft="25px"
android:paddingRight="25px"
/>
<ImageButton
android:id="@+id/button03"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/debraidcard"
android:layout_weight="1"
android:padding="25px"
android:paddingLeft="25px"
android:paddingRight="25px"
/>
</TableRow>
Run Code Online (Sandbox Code Playgroud)
我在我的图像上使用了几种不同的尺寸,我在.jpg和.png之间切换.我接受了几个教程,不喜欢结果.非常感谢任何指导我正确方向的帮助
我有一个ImageButton:
我想放大图像(循环播放图像)。我知道android:scaleType,但我不想一直将图像拉伸到按钮的边界。我只想使其更大一点,例如当前尺寸的120%。
那可能吗?
我想我可能会做一些愚蠢的事情,但我找不到答案.显然,以下事情不起作用,但我该怎么做?
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="+@id/date"
android:text="+@id/heading"
android:text="+@id/subheading"
android:drawableLeft="+@id/featuredimage"
/>
Run Code Online (Sandbox Code Playgroud)
我基本上是制作一篇文章按钮来代表一篇博客文章.我尝试将文本视图放在里面,但它错误地列出了结束标记并引发了错误.
创建其中一个按钮的最佳方法是什么?
我想将图像加载到ImageButton
适配器中,这有时不起作用......我有一个带有 4 个条目的适配器,有时,按钮图像只加载了 2 次而不是 4 次。始终只在第一次创建适配器时......在屏幕旋转左右后,一切正常......但在第一次显示时,它无法正常工作......
具有 4 行的适配器仅在第一次创建时调用 2 次准备和两次加载...
以下是我的适配器getView
:
@Override
public View getView(final int position, View convertView, ViewGroup parent)
{
if (convertView == null)
convertView = LayoutInflater.from(getContext()).inflate(R.layout.row_link, parent, false);
convertView.setTag(R.id.tag_pos, position);
ImageView iconRow = ViewHolder.get(convertView, R.id.icon);
final ImageButton btOpen = ViewHolder.get(convertView, R.id.btOpen);
// this NEVER fails
PicassoTools.getPicasso().load(item.getIconResId()).into(iconRow);
// this sometimes (at the first start) does not work reliable
PicassoTools.getPicasso().load(isAutoLinked ? R.drawable.linked : R.drawable.unlinked).into(new Target()
{
@Override
public void onPrepareLoad(Drawable d)
{
L.d(this, …
Run Code Online (Sandbox Code Playgroud) 我注意到在Chrome中如果你有一个asp.net图像按钮然后鼠标移动然后鼠标移动,最后鼠标向上,则不会触发单击事件.它适用于其他浏览器.有没有人可以解决这个问题?
当我点击它时,我正在尝试制作一个ImageView按钮.我有以下代码:
ImageView button01 = (ImageView) findViewById(R.id.button01);
button01.setOnClickListener(new OnClickListener() {
int button01pos = 0;
public void onClick(View v) {
if (button01pos == 0) {
button01.setImageResource(R.drawable.image01);
button01pos = 1;
} else if (button01pos == 1) {
button01.setImageResource(R.drawable.image02);
button01pos = 0;
}
}
});
Run Code Online (Sandbox Code Playgroud)
但由于某种原因,在Eclipse中,button01以红色加下划线并且它给出了错误:
不能引用在不同方法中定义的内部类中的非final变量button01
有谁知道它为什么这样做以及如何解决它?
谢谢
我正在开发一个使用大量图像按钮进行重定向的系统......但是,每当你将光标放在按钮上时,我希望按钮显示一点点消息...
例如,当您将光标悬停在将您重定向到Schedule上的按钮上时,会出现一条显示"Schedule"的消息.这样,用户可能无法识别图片,但当他将鼠标悬停在按钮上时,他会知道他将被重定向到哪里...
希望你能帮我
我ImageButton
手动声明了一个数组,然后手动添加了一些数组ImageButtons
,在将这些数组分配ImageButtons
给XML布局后,我尝试使用for循环遍历该数组,但是我NullPointerException
在迭代该数组时得到了一个(异常自带)第一次迭代它甚至没有管理迭代一次),这是我的代码:
public ImageButton Antenna, AV, Components, VGA, HDMI, Switch;
public ImageButton[] upControllingButtons = {Antenna, AV, Components, VGA, HDMI, Switch};
Antenna = (ImageButton) findViewById(R.id.antenna);
// then the other six ImageButtons
// setting the onClick for the Up_Controlling butoons
for(int k=0; k < upControllingButtons.length ; k++ ){
upControllingButtons[k].setTag("tag"); // i got the Exception here
}
Run Code Online (Sandbox Code Playgroud)
和ImageButton
XML中的:
<ImageButton
android:id="@+id/antenna"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="7dp"
android:layout_marginRight="7dp"
android:adjustViewBounds="true"
android:background="@drawable/remote_living_buttons"
android:clickable="true"
android:padding="8dp"
android:scaleType="centerInside"
android:src="@drawable/remote_living_antena"
android:tag="released" />
<!.. …
Run Code Online (Sandbox Code Playgroud) 我已经使用此代码制作了一个ImageButton&之后我想在运行时更改它的大小.这两个代码都写在下面,
<ImageButton
android:id="@+id/btn_new"
android:layout_width="50dp"
android:layout_height="50dp"
android:background="@drawable/untitled3"
/>
Run Code Online (Sandbox Code Playgroud)
public void scaler1() {
Display display = getWindowManager().getDefaultDisplay();
int width = display.getWidth();
int height = display.getHeight();
btn_new.setMinimumWidth(width/4);
btn_new.setMinimumHeight(height/6);
}
Run Code Online (Sandbox Code Playgroud)
但它不起作用请给出任何解决方案.
这是我正在使用的实际代码
public void scaler1() {
Display display = getWindowManager().getDefaultDisplay();
int width = display.getWidth();
int height = display.getHeight();
edit_screen.setWidth(width);
edit_screen.setHeight(height / 6);
lpsame = (LayoutParams) btn_0.getLayoutParams();
lpsame.width=width/4;
lpsame.height=height/6;
btn_0.setLayoutParams(lpsame);
LayoutParams lpedit = (LayoutParams) edit_screen.getLayoutParams();
lpedit.width=width;
lpedit.height=height/6;
LayoutParams lpequal = (LayoutParams) btn_0.getLayoutParams();
lpequal.width=width/2;
lpequal.height=height/6;
edit_screen.setLayoutParams(lpedit);
btn_2.setLayoutParams(lpsame);
btn_3.setLayoutParams(lpsame);
btn_4.setLayoutParams(lpsame);
btn_5.setLayoutParams(lpsame);
btn_6.setLayoutParams(lpsame);
btn_7.setLayoutParams(lpsame);
btn_8.setLayoutParams(lpsame);
btn_9.setLayoutParams(lpsame);
btn_add.setLayoutParams(lpsame);
btn_subtrac.setLayoutParams(lpsame); …
Run Code Online (Sandbox Code Playgroud)