GVKun编程网logo

html – 带有自定义图像和文本的表单按钮(html自定义列表图标)

31

以上就是给各位分享html–带有自定义图像和文本的表单按钮,其中也会对html自定义列表图标进行解释,同时本文还将给你拓展android–包含图像和文本的ListView、Android加载进度条,带

以上就是给各位分享html – 带有自定义图像和文本的表单按钮,其中也会对html自定义列表图标进行解释,同时本文还将给你拓展android – 包含图像和文本的ListView、Android加载进度条,带有自定义图像和进度指示器、asp.net – 如何创建包含图像和文本的链接?、delphi – TListbox – 操纵图像和文本的布局?等相关知识,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!

本文目录一览:

html – 带有自定义图像和文本的表单按钮(html自定义列表图标)

html – 带有自定义图像和文本的表单按钮(html自定义列表图标)

表单按钮具有170×60图像,用于非按下和按下状态.我似乎无法做到的是按钮中的文本.我真的想避免编辑图像并直接将文本写入其中.现在我正在使用:

normal.png"
 width="175" height="60" onmousedown="this.src='img/button_pressed2.png'"
 onmouseup="this.src='img/button_normal.png'"> 

我认为不可能在文本之上进行这项工作(据我所知).那么我尝试使用< button>但我也无法让它发挥作用.

我已经能够将文本放在上面的图像上,但是文本在哪里,按钮是不可点击的,这不起作用.

这个问题有什么解决方案?

最佳答案
那么为什么不在常规按钮上编辑背景图像呢?


                  

总结

以上是小编为你收集整理的html – 带有自定义图像和文本的表单按钮全部内容。

如果觉得小编网站内容还不错,欢迎将小编网站推荐给好友。

buttonbuttonbutton

android – 包含图像和文本的ListView

android – 包含图像和文本的ListView

参见英文答案 > Lazy load of images in ListView38个
在左侧创建包含图像的列表视图的方法是什么,在文本之后立即生成文本?
(注意:图像以前是从网上下载的)
提前致谢!

解决方法

这是一个完整的示例代码 Lazy load of images in ListView.您可以重复使用它.

如果列表中有新项,则只需调用adapter.notifyDatasetChanged(),ListView将重新显示所有项目,包括新项目.

适配器中的getView()方法会扩展item.xml并在其中显示实际数据.您需要从一些基本的ListView教程开始,例如Android Series: Custom ListView items and adapters的教程.

Android加载进度条,带有自定义图像和进度指示器

Android加载进度条,带有自定义图像和进度指示器

抱歉,这似乎无关紧要.

我一直在开发我的第一个android应用程序,并希望就实现加载/启动屏幕的最佳方法提供建议.

我的设计师想出了加载/启动屏幕,我不确定如何实现这一点.

>是否请设计师创建一个我可以播放的.gif图像,还是
>我是否在应用程序中编写代码,例如进度条和自行车
从左向右移动,并在完成任务(远程异步任务)时手动将其推到100%,将图像推到最右边以指示完成.

请注意,自行车从左开始,然后继续向右行驶,并带有进度指示器和%.

选项2甚至可能吗?如果可以,请您指出我可以用作指导的任何资源.

loading startup image

谢谢

解决方法:

通常,ProgressBar用于这样的目的,但我认为,应该使用图像中骑自行车的人的Seekbar cuz.您可以通过使用不同的可绘制对象对其进行自定义来实现.

这里有一些有用的教程可以帮助您做到这一点:

> Custom seekbar example
> Create custom seekbar in android

要么

您显然可以使用自定义的ProgressBar,如此处所述:

> Android progress bars
> Customize a progress bar in android

asp.net – 如何创建包含图像和文本的链接?

asp.net – 如何创建包含图像和文本的链接?

我需要为具有图像和图像的ASP.NET页面创建一个链接.文本,单击时将触发Web服务器上的事件.

这就是链接应该是这样的:

如果我不使用ASP.NET,这是HTML链接的样子:

这个问题是我希望能够点击它并触发服务器端事件,但我不知道我是否可以使用普通的旧HTML控件.

使用ASP.NET,我可以看到有各种控件,如ImageButton& HyperLink,但我看不出我怎么能有超链接&一个ImageButton作为相同可点击控件的一部分.

对于我来说,获得类似于绑定到服务器端功能的图像的链接的最佳方法是什么?

最佳答案
你可以这样做..

delphi – TListbox – 操纵图像和文本的布局?

delphi – TListbox – 操纵图像和文本的布局?

我一直在玩TListBox控件,绘制图像和更改字体样式等.我想稍微加强它,并尝试使用缩进和多级缩进来操作项目.

看看这张图片可以获得更好的想法:

我们的想法是列表中位于开始和结束项目之间的项目应相应缩进.

所以,为了给出一个想法,我在Paint中编辑了截图,所以它看起来像这样:

接近这个的方法是什么?我的想法是遍历列表框并在2个单独的变量中返回开始和结束项目的数量,然后以某种方式确定其他项目的位置以及它们之间是否合适 – 但我的逻辑从未如此好:(

为了便于使用,我在下面提供了代码,以显示我如何绘制图像和样式:

unit Unit1;

interface

uses
  Windows,Messages,SysUtils,Variants,Classes,Graphics,Controls,Forms,Dialogs,StdCtrls,ImgList,ComCtrls;

type
  TForm1 = class(TForm)
    ImageList1: timageList;
    PageControl1: TPageControl;
    TabSheet1: TTabSheet;
    ListBox1: TListBox;
    TabSheet2: TTabSheet;
    ListBox2: TListBox;
    TabSheet3: TTabSheet;
    ListBox3: TListBox;
    procedure FormCreate(Sender: TObject);
    procedure ListBox1MeasureItem(Control: TWinControl; Index: Integer;
      var Height: Integer);
    procedure ListBox1DrawItem(Control: TWinControl; Index: Integer;
      Rect: TRect; State: TOwnerDrawState);
    procedure ListBox2MeasureItem(Control: TWinControl; Index: Integer;
      var Height: Integer);
    procedure ListBox2DrawItem(Control: TWinControl; Index: Integer;
      Rect: TRect; State: TOwnerDrawState);
    procedure ListBox3MeasureItem(Control: TWinControl; Index: Integer;
      var Height: Integer);
    procedure ListBox3DrawItem(Control: TWinControl; Index: Integer;
      Rect: TRect; State: TOwnerDrawState);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

// assign quick identifiers to image indexes
const
  imgLayout      = 0;
  imgCalculator  = 1;
  imgComment     = 2;
  imgTime        = 3;
  imgStart       = 4;
  imgEnd         = 5;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
var
  ListStyle: TListBoxStyle;
begin
  // set the listBox style here
  ListStyle := lbOwnerDrawVariable;
  ListBox1.Style := ListStyle;
  ListBox2.Style := ListStyle;
  ListBox3.Style := ListStyle;
end;

{******************************************************************************}

procedure TForm1.ListBox1DrawItem(Control: TWinControl; Index: Integer;
  Rect: TRect; State: TOwnerDrawState);
var
  TextPosition: Integer;
  Images: timageList;
begin
  TListBox(Control).Canvas.FillRect(Rect);
  Images := ImageList1;

  // draw the images
  if TListBox(Control).Items.Strings[Index] = 'Layout' then
  begin
    Images.Draw(TListBox(Control).Canvas,Rect.Left + 4,Rect.Top,imgLayout);
  end else
  if TListBox(Control).Items.Strings[Index] = 'Calculator' then
  begin
    Images.Draw(TListBox(Control).Canvas,imgCalculator);
  end else
  if TListBox(Control).Items.Strings[Index] = 'Comment' then
  begin
    Images.Draw(TListBox(Control).Canvas,imgComment);
  end else
  if TListBox(Control).Items.Strings[Index] = 'Time' then
  begin
    Images.Draw(TListBox(Control).Canvas,imgTime);
  end;

  // positions the text
  TextPosition := (Rect.Bottom - Rect.Top - TListBox(Control).Canvas.TextHeight
    (Text)) div 2;

  // displays the text
  TListBox(Control).Canvas.textout(Rect.Left + Images.Width + 8,Rect.Top + TextPosition,TListBox(Control).Items.Strings[index]);
end;

procedure TForm1.ListBox1MeasureItem(Control: TWinControl; Index: Integer;
  var Height: Integer);
begin
  Height := ImageList1.Height;
end;

{******************************************************************************}

procedure TForm1.ListBox2DrawItem(Control: TWinControl; Index: Integer;
  Rect: TRect; State: TOwnerDrawState);
var
  TextPosition: Integer;
  Images: timageList;
begin
  TListBox(Control).Canvas.FillRect(Rect);
  Images := ImageList1;

  // draw the images
  if TListBox(Control).Items.Strings[Index] = 'Layout' then
  begin
    Images.Draw(TListBox(Control).Canvas,imgLayout);
    TListBox(Control).Canvas.Font.Style := [fsBold];
  end else
  if TListBox(Control).Items.Strings[Index] = 'Calculator' then
  begin
    Images.Draw(TListBox(Control).Canvas,imgCalculator);
    TListBox(Control).Canvas.Font.Color := clBlue;
    TListBox(Control).Canvas.Font.Style := [fsItalic];
  end else
  if TListBox(Control).Items.Strings[Index] = 'Comment' then
  begin
    Images.Draw(TListBox(Control).Canvas,imgComment);
    TListBox(Control).Canvas.Font.Color := clRed;
  end else
  if TListBox(Control).Items.Strings[Index] = 'Time' then
  begin
    Images.Draw(TListBox(Control).Canvas,TListBox(Control).Items.Strings[index]);
end;

procedure TForm1.ListBox2MeasureItem(Control: TWinControl; Index: Integer;
  var Height: Integer);
begin
  Height := ImageList1.Height;
end;

{******************************************************************************}

procedure TForm1.ListBox3DrawItem(Control: TWinControl; Index: Integer;
  Rect: TRect; State: TOwnerDrawState);
var
  TextPosition: Integer;
  Images: timageList;
begin
  TListBox(Control).Canvas.FillRect(Rect);
  Images := ImageList1;

  // draw the images
  if TListBox(Control).Items.Strings[Index] = 'Layout' then
  begin
    Images.Draw(TListBox(Control).Canvas,imgTime);
  end else
  if TListBox(Control).Items.Strings[Index] = 'Start' then
  begin
    Images.Draw(TListBox(Control).Canvas,imgStart);
    TListBox(Control).Canvas.Font.Style := [fsBold];
  end else
  if TListBox(Control).Items.Strings[Index] = 'End' then
  begin
    Images.Draw(TListBox(Control).Canvas,imgEnd);
    TListBox(Control).Canvas.Font.Style := [fsBold];
  end;

  // positions the text
  TextPosition := (Rect.Bottom - Rect.Top - TListBox(Control).Canvas.TextHeight
    (Text)) div 2;

  // displays the text
  TListBox(Control).Canvas.textout(Rect.Left + Images.Width + 8,TListBox(Control).Items.Strings[index]);
end;

procedure TForm1.ListBox3MeasureItem(Control: TWinControl; Index: Integer;
  var Height: Integer);
begin
  Height := ImageList1.Height;
end;

{******************************************************************************}

end.

我会很感激如何确定如何操纵物品.我知道我可以更改位图和文本的位置,但它确定项目是否属于组之间,以及是否设置了正确的缩进级别.

我希望这是有道理的,这就是为什么我放一些模拟图片.

谢谢 :)

PS,我从不写小帖对不起!

更新工作演示

我接受了Sertac的回答,我完全感谢Sertac.

为了帮助那些可能正在观看的人 – 而且因为我一直在学习OOP,我想展示我的代码,看看它是否有用:)

我创建了2个单元,Lib.pas包含列表项的类,Unit1.pas是Form1单元(我缩短了单元1,以便更清楚地看到发生了什么):

Lib.pas

unit Lib;

interface

uses
  Classes,StdCtrls;

type
  TMyListData = class(TObject)
  public
    fCaption: string;
    fImageIndex: integer;
  public
    property Caption: string read fCaption write fCaption;
    property ImageIndex: integer read fImageIndex write fImageIndex;

    constructor Create;
    destructor Destroy; override;
  end;

type
  TLayoutItem     = class(TMyListData);
  TCalculatorItem = class(TMyListData);
  TCommentItem    = class(TMyListData);
  TTimeItem       = class(TMyListData);
  TStartItem      = class(TMyListData);
  TEndItem        = class(TMyListData);

const
  imgLayout       = 0;
  imgCalculator   = 1;
  imgComment      = 2;
  imgTime         = 3;
  imgStart        = 4;
  imgEnd          = 5;

procedure NewLayoutItem(aListBox: TListBox);
procedure NewCalculatorItem(aListBox: TListBox);
procedure NewCommentItem(aListBox: TListBox);
procedure NewTimeItem(aListBox: TListBox);
procedure NewStartItem(aListBox: TListBox);
procedure NewEndItem(aListBox: TListBox);
procedure DeleteItem(aListBox: TListBox; aIndex: integer);
procedure CalculateIndents(aListBox: TListBox);

implementation

{ TMyListData }

constructor TMyListData.Create;
begin
  inherited Create;
end;

destructor TMyListData.Destroy;
begin
  inherited;
end;

procedure NewLayoutItem(aListBox: TListBox);
var
  Obj: TLayoutItem;
begin
  Obj := TLayoutItem.Create;
  try
    Obj.Caption := 'Layout';
    Obj.ImageIndex := imgLayout;

    aListBox.AddItem(Obj.Caption,Obj);
  finally
    Obj.Free;
  end;

  CalculateIndents(aListBox);
end;

procedure NewCalculatorItem(aListBox: TListBox);
var
  Obj: TCalculatorItem;
begin
  Obj := TCalculatorItem.Create;
  try
    Obj.Caption := 'Calculator';
    Obj.ImageIndex := imgCalculator;

    aListBox.AddItem(Obj.Caption,Obj);
  finally
    Obj.Free;
  end;

  CalculateIndents(aListBox);
end;

procedure NewCommentItem(aListBox: TListBox);
var
  Obj: TCommentItem;
begin
  Obj := TCommentItem.Create;
  try
    Obj.Caption := 'Comment';
    Obj.ImageIndex := imgComment;

    aListBox.AddItem(Obj.Caption,Obj);
  finally
    Obj.Free;
  end;

  CalculateIndents(aListBox);
end;

procedure NewTimeItem(aListBox: TListBox);
var
  Obj: TTimeItem;
begin
  Obj := TTimeItem.Create;
  try
    Obj.Caption := 'Time';
    Obj.ImageIndex := imgTime;

    aListBox.AddItem(Obj.Caption,Obj);
  finally
    Obj.Free;
  end;

  CalculateIndents(aListBox);
end;

procedure NewStartItem(aListBox: TListBox);
var
  Obj: TStartItem;
begin
  Obj := TStartItem.Create;
  try
    Obj.Caption := 'Start';
    Obj.ImageIndex := imgStart;

    aListBox.AddItem(Obj.Caption,Obj);
  finally
    Obj.Free;
  end;

  CalculateIndents(aListBox);
end;

procedure NewEndItem(aListBox: TListBox);
var
  Obj: TEndItem;
begin
  Obj := TEndItem.Create;
  try
    Obj.Caption := 'End';
    Obj.ImageIndex := imgEnd;

    aListBox.AddItem(Obj.Caption,Obj);
  finally
    Obj.Free;
  end;

  CalculateIndents(aListBox);
end;


procedure DeleteItem(aListBox: TListBox; aIndex: integer);
begin
  aListBox.Items.Delete(aIndex);
  aListBox.Items.Objects[aIndex] := nil;

  CalculateIndents(aListBox);
end;

procedure CalculateIndents(aListBox: TListBox);
var
  i: Integer;
  Indent: Integer;
begin
  Indent := 0;

  for i := 0 to aListBox.Items.Count - 1 do
  begin
    if aListBox.Items[i] = 'End' then
      Dec(Indent);

    if Indent > -1 then
      aListBox.Items.Objects[i] := Pointer(Indent);

    if aListBox.Items[i] = 'Start' then
      Inc(Indent);
  end;

  for i := aListBox.Items.Count - 1 downto 0 do
  begin
    if (aListBox.Items[i] = 'End') and (Indent = -1) then
    begin
      DeleteItem(aListBox,i);
      Break;
    end;
  end;
end;

end.

Unit1.pas

unit Unit1;

interface

uses
  Windows,ComCtrls,Buttons;

type
  TForm1 = class(TForm)
    ImageList1: timageList;
    lbMain: TListBox;
    btnLayout: TBitBtn;
    btncalculator: TBitBtn;
    btnComment: TBitBtn;
    btnTime: TBitBtn;
    btnStartGroup: TBitBtn;
    btnEndGroup: TBitBtn;
    btnDelete: TBitBtn;
    procedure FormCreate(Sender: TObject);
    procedure lbMainMeasureItem(Control: TWinControl; Index: Integer;
      var Height: Integer);
    procedure lbMainDrawItem(Control: TWinControl; Index: Integer;
      Rect: TRect; State: TOwnerDrawState);
    procedure btnLayoutClick(Sender: TObject);
    procedure btncalculatorClick(Sender: TObject);
    procedure btnCommentClick(Sender: TObject);
    procedure btnTimeClick(Sender: TObject);
    procedure btnStartGroupClick(Sender: TObject);
    procedure btnEndGroupClick(Sender: TObject);
    procedure btnDeleteClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

uses
  Lib;

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
  // set the listBox style here
  lbMain.Style := lbOwnerDrawVariable;
end;

procedure TForm1.lbMainDrawItem(Control: TWinControl; Index: Integer;
  Rect: TRect; State: TOwnerDrawState);
var
  TextPosition: Integer;
  Images: timageList;
begin
  TListBox(Control).Canvas.FillRect(Rect);
  Images := ImageList1;

  // draw the images
  if TListBox(Control).Items.Strings[Index] = 'Layout' then
  begin
    Images.Draw(TListBox(Control).Canvas,Rect.Left + 4 +
                8 * Integer(TListBox(Control).Items.Objects[Index]),imgLayout);
  end
  else if TListBox(Control).Items.Strings[Index] = 'Calculator' then
  begin
    Images.Draw(TListBox(Control).Canvas,imgCalculator);
  end
  else if TListBox(Control).Items.Strings[Index] = 'Comment' then
  begin
    Images.Draw(TListBox(Control).Canvas,imgComment);
  end
  else if TListBox(Control).Items.Strings[Index] = 'Time' then
  begin
    Images.Draw(TListBox(Control).Canvas,imgTime);
  end
  else if TListBox(Control).Items.Strings[Index] = 'Start' then
  begin
    Images.Draw(TListBox(Control).Canvas,imgStart);
  end
  else if TListBox(Control).Items.Strings[Index] = 'End' then
  begin
    Images.Draw(TListBox(Control).Canvas,imgEnd);
  end;

  // positions the text
  TextPosition := (Rect.Bottom - Rect.Top - TListBox(Control).Canvas.TextHeight
    (Text)) div 2;

  // displays the text
  TListBox(Control).Canvas.textout(
    Rect.Left + Images.Width + 8 + 8 * Longint(TListBox(Control).Items.Objects[Index]),TListBox(Control).Items.Strings[index]);
end;

procedure TForm1.lbMainMeasureItem(Control: TWinControl; Index: Integer;
  var Height: Integer);
begin
  Height := ImageList1.Height;
end;

procedure TForm1.btnLayoutClick(Sender: TObject);
begin
  NewLayoutItem(lbMain);
end;

procedure TForm1.btncalculatorClick(Sender: TObject);
begin
  NewCalculatorItem(lbMain);
end;

procedure TForm1.btnCommentClick(Sender: TObject);
begin
  NewCommentItem(lbMain);
end;

procedure TForm1.btnTimeClick(Sender: TObject);
begin
  NewTimeItem(lbMain);
end;

procedure TForm1.btnStartGroupClick(Sender: TObject);
begin
  NewStartItem(lbMain);
end;

procedure TForm1.btnEndGroupClick(Sender: TObject);
begin
  NewEndItem(lbMain);
end;

procedure TForm1.btnDeleteClick(Sender: TObject);
begin
  if lbMain.ItemIndex <> -1 then
  begin
    DeleteItem(lbMain,lbMain.ItemIndex);
  end;
end;

end.

它可以做得更好,即根据Items.Objects []属性分配图像索引但这完全有效:)

解决方法

一种方法是迭代项目并修改文本以指示缩进:
procedure TForm1.FormCreate(Sender: TObject);
var
  i: Integer;
  Indent: Integer;
begin

  ...

  Indent := 0;
  for i := 0 to ListBox3.Items.Count - 1 do begin
    if Pos('End',ListBox3.Items[i]) > 0 then
      Dec(Indent);
    if Indent > 0 then
      ListBox3.Items[i] := StringOfChar(#32,2 * Indent) + ListBox3.Items[i];
    if Pos('Start',ListBox3.Items[i]) > 0 then
      Inc(Indent);
  end;
end;

由于项目的文本已更改,因此此方法需要在绘制时相应地测试文本:

procedure TForm1.ListBox3DrawItem(Control: TWinControl; Index: Integer;
  Rect: TRect; State: TOwnerDrawState);
var
  TextPosition: Integer;
  Images: timageList;
begin
  TListBox(Control).Canvas.FillRect(Rect);
  Images := ImageList1;

  // draw the images
  if Pos('Layout',TListBox(Control).Items.Strings[Index]) > 0 then
  begin
    Images.Draw(TListBox(Control).Canvas,imgLayout);
  end else
  if Pos('Calculator',TListBox(Control).Items.Strings[Index]) > 0 then
    ..

(使用这种方法,缩进图像会有点工作,计算项目文本中的前导空格,依此类推……)

如果项目的对象尚未使用,则稍微更好的方法是将缩进存储为整数,并在绘制时使用该信息.例如.迭代时:

Indent := 0;
for i := 0 to ListBox3.Items.Count - 1 do begin
  if ListBox3.Items[i] = 'Start' then
    Inc(Indent);
  ListBox3.Items.Objects[i] := Pointer(Indent);
  if ListBox3.Items[i] = 'End' then
    Dec(Indent);
end;

绘图时:

..
  if TListBox(Control).Items.Strings[Index] = 'Layout' then
  begin
    Images.Draw(TListBox(Control).Canvas,imgLayout);

  ..
  // displays the text
  TListBox(Control).Canvas.textout(
    Rect.Left + Images.Width + 8 + 8 * Longint(TListBox(Control).Items.Objects[Index]),TListBox(Control).Items.Strings[index]);
  ..

今天关于html – 带有自定义图像和文本的表单按钮html自定义列表图标的分享就到这里,希望大家有所收获,若想了解更多关于android – 包含图像和文本的ListView、Android加载进度条,带有自定义图像和进度指示器、asp.net – 如何创建包含图像和文本的链接?、delphi – TListbox – 操纵图像和文本的布局?等相关知识,可以在本站进行查询。

本文标签: